Esempio n. 1
0
        private void SetupEnvironment()
        {
            var configs = new MongoDbConfigurations()
            {
                Host     = "test",
                Port     = 27017,
                Database = "TestDB"
            };

            _context = new ShoppingCartContext(configs);
        }
        public void ShoppingCartContext_Initialize_Success()
        {
            // Arrange
            var configs = new MongoDbConfigurations()
            {
                Host     = "test",
                Port     = 27017,
                Database = "TestDB"
            };

            // Act
            var context = new ShoppingCartContext(configs);

            // Assert
            Assert.NotNull(context);
        }
Esempio n. 3
0
        public ShoppingCartContext(MongoDbConfigurations config)
        {
            _mongoDbConfigurations = config;

            MongoCredential credential = MongoCredential.CreateCredential(config.MasterDatabaseName, config.User, config.Password);

            var settings = new MongoClientSettings
            {
                Credential = credential,
                Server     = new MongoServerAddress(config.Host, config.Port)
            };

            _mongoClient = new MongoClient(settings);

            _mongoDatabase = _mongoClient.GetDatabase(config.Database);
        }
        private void SetupEnvironment()
        {
            var dbGuid = new Guid();

            var configs = new MongoDbConfigurations()
            {
                Database = dbGuid.ToString(),
                Host     = "localhost",
                Port     = 27017,
                User     = "******",
                Password = "******"
            };

            _context = new ShoppingCartContext(configs);

            _itemRepository = new ItemRepository(_context);
        }
        private void SetupEnvironment()
        {
            var dbGuid = Guid.NewGuid();

            var configs = new MongoDbConfigurations()
            {
                Database           = $"test_dv_{dbGuid.ToString()}",
                Host               = "localhost",
                Port               = 27017,
                User               = "******",
                Password           = "******",
                MasterDatabaseName = "admin"
            };

            _context = new ShoppingCartContext(configs);

            _itemRepository = new ItemRepository(_context);
            _cartRepository = new CartRepository(_context);
        }
        public ShoppingCartTester()
        {
            var dbGuid = Guid.NewGuid();

            var configs = new MongoDbConfigurations()
            {
                Database = dbGuid.ToString(),
                Host     = "localhost",
                Port     = 27017,
                User     = "******",
                Password = "******"
            };

            Context = new ShoppingCartContext(configs);

            StockCache = new StockCacheInMemory();

            ItemRepository = new ItemRepository(Context);
            CartRepository = new CartRepository(Context);

            CartService = new CartService(ItemRepository, CartRepository, StockCache);
        }