public async Task TestIndex() { var user = await context.Users.Put(new User() { Id = ShortGuid.NewId(), Name = $"User2", Email = $"*****@*****.**", PasswordHash = "kdsjfihsd09fy9y4rhiosf", }); var entity = await context.OwnedEntities.Put(new OwnedEntity() { OwnerId = user.Id, Id = ShortGuid.NewId(), Created = DateTime.UtcNow, Name = "OwnedEntity2" }); var result = await context.OwnedEntities.WithIndex("OwnerId-Type-Index").Query() .WithPrimaryKey(user.Id).WithSecondaryKey().Equal("OwnedEntity") .Get(); Assert.AreEqual(result.Length, 1); await context.Users.Delete(user); await context.OwnedEntities.Delete(entity); }
public async Task TestQuery() { var user = await context.Users.Put(new User() { Id = ShortGuid.NewId(), Type = "User", Name = $"User1", Email = $"*****@*****.**", PasswordHash = "kdsjfihsd09fy9y4rhiosf", }); var (items, count, pageToken) = await context.Users.Query().WithPrimaryKey(user.Id).WithSecondaryKey().Equal("User") .WithFilter("Email").BeginsWith("user").Get(1); await context.Users.Delete(user); Assert.AreEqual(count, 1); }
public async Task TestPutDelete() { var user = await context.Users.Put(new User() { Id = ShortGuid.NewId(), Type = "User", Name = $"User1", Email = $"*****@*****.**", PasswordHash = "kdsjfihsd09fy9y4rhiosf", }); user = await context.Users.Find(user.Id, "User"); Assert.IsNotNull(user); await context.Users.Delete(user); user = await context.Users.Find(user.Id, "User"); Assert.IsNull(user); }
public static async Task Initialize(TestContext testContext) { context = new MyMemoryDbContext(); for (var i = 0; i < 50; i++) { var user = await context.Users.Put(new User() { Id = ShortGuid.NewId(), Name = $"User{i}", Email = $"user{i}@user.com", PasswordHash = $"{((i*Math.PI)%i).GetHashCode().ToString()}", }); for (var e = 0; e < 100; e++) { var entity = await context.OwnedEntities.Put(new OwnedEntity() { OwnerId = user.Id, Id = ShortGuid.NewId(), Created = DateTime.UtcNow, Name = $"OwnedEntity{e}" }); } for (var e = 0; e < 100; e++) { var entity = await context.Entities <OwnedEntity2>().Put(new OwnedEntity2() { OwnerId = user.Id, Id = ShortGuid.NewId(), Created = DateTime.UtcNow, Name = $"OwnedEntity2{e}" }); } if (i == 34) { userId = user.Id; } } }