public async Task ListRecordsFilterTest(DateTimeOffset?startTime, DateTimeOffset?endTime, IList <Guid> expectedIds) { var userId = Guid.NewGuid().ToString(); var filter = new FilterOptions(startTime, endTime); var records = CreateRecords(userId); using (var context = GetContext()) { await context.NotificationRecords.AddRangeAsync(records); await context.SaveChangesAsync(); } using (var context = GetContext()) { var store = new NotificationRecordDataStore(context, DefaultMapper); var results = await store.ListAsync(userId, 5, filter); Assert.NotNull(results); expectedIds.All(x => { Assert.Contains(results, y => y.Id == x); return(true); }); } }
public async Task ListRecordsPageSizeTest(int size, int expectedSize) { var userId = Guid.NewGuid().ToString(); var records = CreateRecords(userId); using (var context = GetContext()) { await context.NotificationRecords.AddRangeAsync(records); await context.SaveChangesAsync(); } using (var context = GetContext()) { var store = new NotificationRecordDataStore(context, DefaultMapper); var results = await store.ListAsync(userId, size); Assert.NotNull(results); Assert.Equal(expectedSize, results.Count()); var expected = records.OrderByDescending(x => x.Created).Take(size).ToList(); expected.ForEach(x => Assert.Contains(results, y => y.Id == x.Id)); Assert.Equal(records.Last().Id, results.First().Id); } }