private UserDbModel CreateTestUserDbModel(MongoDbContext dbContext, string containerName) { UserDbModel model = TestDbModelHelper.GetUserDbModel(); dbContext.InsertAsync <UserDbModel>(containerName, model).Wait(); return(model); }
public void InsertAsync_InsertsEntity() { string containerName = $"GetOneAsync_{Guid.NewGuid()}"; MongoDbContext dbContext = CreateDbContext(); // execute UserDbModel model = TestDbModelHelper.GetUserDbModel(); UserDbModel insertedModel = dbContext.InsertAsync <UserDbModel>(containerName, model).GetAwaiter().GetResult(); var filterDef = new FilterDefinitionBuilder <UserDbModel>(); var filter = filterDef.Eq(x => x.Id, model.Id); UserDbModel fetchResult = dbContext.GetOneAsync <UserDbModel>(containerName, filter).GetAwaiter().GetResult(); Assert.IsNotNull(model.Id, insertedModel.Id); Assert.IsNotNull(fetchResult.Id, insertedModel.Id); DeleteTestDatabase(dbContext); }