added tests for the sumbyasync methods
This commit is contained in:
@@ -1068,6 +1068,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, TKey>(documents);
|
||||
var expectedSum = documents.Sum(e => e.Nested.SomeAmount);
|
||||
|
||||
// Act
|
||||
var result = await SUT.SumByAsync<T, TKey>(e => e.SomeContent == criteria, e => e.Nested.SomeAmount, PartitionKey);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedSum, result);
|
||||
}
|
||||
|
||||
#endregion Math
|
||||
|
||||
#region Test Utils
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private string GetCurrentMethod()
|
||||
|
||||
Reference in New Issue
Block a user