public async Task <User> GetUser(string userName, string password) { using var mg = new MongoDatabaseContext(AppSettings.ConnectionString_MongoDB, AppSettings.MongoDB_ServerDetectionDatabase); var builder = new FilterDefinitionBuilder <User>(); var filter = builder.Eq(t => t.UserName, userName) & builder.Eq(t => t.Password, password); return(await mg.GetFirstDocumentAsync <User>(AppSettings.MongoDB_UserCollection, filter)); }
public async Task CreateProductAsync_ProductCreated() { //Arrange await MongoDatabase.RecreateAsync(); //Act await _functions.CreateProductAsync(null); //Assert MongoDatabaseContext context = MongoDatabase.GetMongoDatabaseContext(); Product product = await context.Products.AsQueryable().SingleAsync(); Assert.NotEqual(Guid.NewGuid(), product.Id); Assert.Equal("Surface Headphones", product.Name); Assert.Equal("Mobile Devices", product.Category); Assert.Equal(250, product.Price); }
public ProductsFunctionsTests() { MongoDatabaseContext context = MongoDatabase.GetMongoDatabaseContext(); _functions = new ProductsFunctions(context); }
public BaseRepository(IDatabaseContext databaseContext) { _collectionName = Utility.GetEntityName <T>(); _databaseContext = (MongoDatabaseContext)databaseContext; _collection = _databaseContext.MongoDatabase.GetCollection <T>(_collectionName); }
public ProductsFunctionsTests(IntegrationFixture fixture) { MongoDatabaseContext context = fixture.Services.GetRequiredService <MongoDatabaseContext>(); _functions = new ProductsFunctions(context); }
public ProductsFunctions(MongoDatabaseContext mongoDatabaseContext) { _mongoDatabaseContext = mongoDatabaseContext; }
public Director(MongoDatabaseContext mongoDatabaseContext) { databaseContext = mongoDatabaseContext; }
public MongoDatabaseConnector(IDatabaseContext dbcontext) { _dbcontext = (MongoDatabaseContext)dbcontext; _collectionName = Utility.GetEntityName <T>(); _collection = _dbcontext.MongoDatabase.GetCollection <T>(_collectionName); }