Esempio n. 1
0
        public async Task AdminProductsService_AddProductAsync()
        {
            AddAndEditProductBindingModel model = new AddAndEditProductBindingModel()
            {
                Price = 2, Name = "Ring", CategoryId = "1", PictureUrl = "https://media.tiffany.com/is/image/Tiffany/1X/20180403_CB_Necklaces_and_Pendants_Tile2_3x2Promo_US_paloma_picasso_something_to_love.jpg?v=20180322135418"
            };

            dbContext.SaveChanges();
            var service = new AdminProductsService(dbContext, this.mapper);
            await service.AddProductAsync(model);

            Assert.IsNotNull(dbContext.Products.FirstOrDefault(c => c.Id == 1 && c.Name == "Ring"));
            Assert.IsNotNull(dbContext.Products.FirstOrDefault(c => c.Id == 1 && c.Name == "Ring").PictureUrl);
        }
Esempio n. 2
0
        public async Task AdminProductsService_AddCategoryAsync()
        {
            AddCategoryBindingModel model = new AddCategoryBindingModel()
            {
                Name = "Ring"
            };

            dbContext.SaveChanges();

            var service = new AdminProductsService(dbContext, this.mapper);

            await service.AddCategoryAsync(model);

            Assert.IsNotNull(dbContext.Categories.FirstOrDefault(c => c.Name == "Ring"));
        }
Esempio n. 3
0
        public async Task AdminProductsService_AddGiftCart()
        {
            AddGiftCardBindingModel model = new AddGiftCardBindingModel()
            {
                Code = "8888", Discount = 88
            };

            dbContext.SaveChanges();

            var service = new AdminProductsService(dbContext, this.mapper);

            await service.AddGiftCardAsync(model);

            Assert.IsNotNull(dbContext.GiftCards.FirstOrDefault(c => c.Code == "8888"));
            Assert.IsNotNull(dbContext.GiftCards.FirstOrDefault(c => c.Discount == 88));
        }
Esempio n. 4
0
        public void InitializeTests()
        {
            this._dbContext = MockDbContext.GetContext();
            this._mapper    = MockAutoMapper.GetAutoMapper();
            this._service   = new AdminProductsService(this._dbContext, this._mapper);

            this._dbContext.Manufacturers.Add(new Manufacturer()
            {
                Id = 1, Name = string.Format(TestsConstants.Manufacturer, 1)
            });
            this._dbContext.SaveChanges();

            this._dbContext.Products.Add(new Product()
            {
                Id             = 1,
                Name           = string.Format(TestsConstants.Product, 1),
                Type           = string.Format(TestsConstants.Type, 1),
                ManufacturerId = 1
            });
            this._dbContext.SaveChanges();
        }
Esempio n. 5
0
        public void InitializeTests()
        {
            this.dbContext = MockDbContext.GetContext();
            this.mapper    = MockAutoMapper.GetAutoMapper();
            this.service   = new AdminProductsService(this.dbContext, this.mapper);

            this.dbContext.Teams.Add(new Team()
            {
                Id = 1, Name = string.Format(TestsConstants.Team, 1)
            });
            this.dbContext.SaveChanges();

            this.dbContext.Products.Add(new Product()
            {
                Id     = 1,
                Title  = string.Format(TestsConstants.Product, 1),
                Brand  = string.Format(TestsConstants.Brand, 1),
                TeamId = 1
            });
            this.dbContext.SaveChanges();
        }
        public IAdminProductsService GetService(OnlineStoreDbContext dbContext)
        {
            var service = new AdminProductsService(dbContext, this.mapper);

            return(service);
        }