Skip to content

Commit

Permalink
feat: add terms query unit test of datetime type
Browse files Browse the repository at this point in the history
  • Loading branch information
AElfBourneShi committed Oct 19, 2024
1 parent f5d445e commit 47a3326
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +596,15 @@ public async Task GetList_Nested_Test()
[Fact]
public async Task GetList_Terms_Test()
{
var timeNow = DateTime.Now;
for (int i = 1; i <= 7; i++)
{
var blockIndex = new BlockIndex
{
Id = "block" + i,
BlockHash = "BlockHash" + i,
BlockHeight = i,
BlockTime = DateTime.Now.AddDays(-10 + i),
BlockTime = timeNow.AddDays(i),
LogEventCount = i,
ChainId = "AELF"
};
Expand All @@ -627,14 +628,22 @@ public async Task GetList_Terms_Test()

var filterList = queryable.Where(item => inputs.Contains(item.BlockHash)).ToList();
filterList.Count.ShouldBe(3);

List<long> heights = new List<long>()
{
4, 5
};
Expression<Func<BlockIndex, bool>> mustQuery = item => heights.Contains(item.BlockHeight);
var filterList_heights = queryable.Where(mustQuery).ToList();
filterList_heights.Count.ShouldBe(2);

List<DateTime> times = new List<DateTime>()
{
DateTime.Now, timeNow.AddDays(1), timeNow.AddDays(2)
};
Expression<Func<BlockIndex, bool>> termsQuery = item => times.Contains(item.BlockTime);
var filterList_times = queryable.Where(termsQuery).ToList();
filterList_times.Count.ShouldBe(2);
}

[Fact]
Expand Down

0 comments on commit 47a3326

Please sign in to comment.