added tests for the sumbyasync methods

This commit is contained in:
Alexandre SPIESER
2019-02-04 23:11:36 +00:00
parent eaa90d67f5
commit 4ac0ffe91c
8 changed files with 158 additions and 19 deletions
@@ -1075,6 +1075,33 @@ namespace CoreIntegrationTests.Infrastructure
#endregion Index Management
#region Math
[Fact]
public async Task SumByAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.Nested.SomeAmount = 5m;
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedSum = documents.Sum(e => e.Nested.SomeAmount);
// Act
var result = await SUT.SumByAsync<T>(e => e.SomeContent == criteria, e => e.Nested.SomeAmount, PartitionKey);
// Assert
Assert.Equal(expectedSum, result);
}
#endregion Math
#region Test Utils
[MethodImpl(MethodImplOptions.NoInlining)]