public async Task TestFilterByDateYear() { //SETUP var options = this.GetCosmosDbOptions <Ch16CosmosDbContext>(); using var context = new Ch16CosmosDbContext(options); await context.Database.EnsureDeletedAsync(); await context.Database.EnsureCreatedAsync(); var item1 = new CosmosGuidKey { MyDateTime = new DateTime(2000, 1, 1), MyTimSpan = new TimeSpan(1, 2, 3, 4) }; var item2 = new CosmosGuidKey { MyDateTime = new DateTime(3000, 1, 1), MyTimSpan = new TimeSpan(4, 3, 2, 1) }; context.AddRange(item1, item2); await context.SaveChangesAsync(); //ATTEMPT context.ChangeTracker.Clear(); var readBook = await context.GuidKeyItems.Where(x => x.MyDateTime < new DateTime(2100, 1, 1)).ToListAsync(); //VERIFY readBook.Count.ShouldEqual(1); }
public async Task TestWriteItemCompositeKeyAuto() { //SETUP var options = this.GetCosmosDbOptions <Ch16CosmosDbContext>(); using var context = new Ch16CosmosDbContext(options); await context.Database.EnsureDeletedAsync(); await context.Database.EnsureCreatedAsync(); //ATTEMPT var item1 = new CosmosCompositeKey { Key1 = Guid.NewGuid(), Key2 = 1 }; var item2 = new CosmosCompositeKey { Key1 = Guid.NewGuid(), Key2 = 2 }; context.AddRange(item1, item2); await context.SaveChangesAsync(); //VERIFY context.ChangeTracker.Clear(); var readBook = await context.ComKeyItems.ToListAsync(); readBook.Count.ShouldEqual(2); }