Beispiel #1
0
        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));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public ProductsFunctionsTests()
        {
            MongoDatabaseContext context = MongoDatabase.GetMongoDatabaseContext();

            _functions = new ProductsFunctions(context);
        }
Beispiel #4
0
 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);
 }