Exemplo n.º 1
0
        public async Task SoftDelete_WithInValidCustomCakeId_ShouldMarkCakeAsDeleted()
        {
            //Assert
            var db   = this.SetDb();
            var repo = new Repository <CustomCakeImg>(db);
            var mock = new Mock <ILogger <CustomCakeService> >();
            ILogger <CustomCakeService> logger = mock.Object;
            var productRepo = new Repository <Product>(db);

            var productService = new CakeService(null, productRepo, this.Mapper);

            var service = new CustomCakeService(productRepo, repo, this.Mapper, logger);

            CustomCakeOrderViewModel model = new CustomCakeOrderViewModel
            {
                Sponge           = "Vanilla",
                FirstLayerCream  = "Whipped",
                SecondLayerCream = "Whipped",
                Filling          = "No_Filling",
                SideDecoration   = "White_Chocolate_Cigarettes",
                TopDecoration    = "Habana",
                NumberOfSlices   = 6,
                Img = null,
            };

            var product = service.CreateCustomProduct(model);

            await productService.AddCakeToDb(product);

            //Act


            //Assert
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await productService.SoftDelete(2));
        }
Exemplo n.º 2
0
        public async Task SoftDelete_WithValidId_ShouldMarkCakeAsIsDeleted()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedProducts(db);

            var repo = new Repository <Product>(db);

            var service = new CakeService(null, repo, this.Mapper);

            //Act
            await service.SoftDelete(1);

            var expected = true;
            var actual   = repo.All().SingleOrDefault(p => p.Id == 1).IsDeleted;

            //Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 3
0
        public async Task SoftDelete_WithValidCustomCakeId_ShouldMarkCakeAsDeleted()
        {
            //Assert
            var db   = this.SetDb();
            var repo = new Repository <CustomCakeImg>(db);
            var mock = new Mock <ILogger <CustomCakeService> >();
            ILogger <CustomCakeService> logger = mock.Object;
            var productRepo = new Repository <Product>(db);

            var productService = new CakeService(null, productRepo, this.Mapper);

            var service = new CustomCakeService(productRepo, repo, this.Mapper, logger);

            CustomCakeOrderViewModel model = new CustomCakeOrderViewModel
            {
                Sponge           = "Vanilla",
                FirstLayerCream  = "Whipped",
                SecondLayerCream = "Whipped",
                Filling          = "No_Filling",
                SideDecoration   = "White_Chocolate_Cigarettes",
                TopDecoration    = "Habana",
                NumberOfSlices   = 6,
                Img = null,
            };

            var product = service.CreateCustomProduct(model);

            await productService.AddCakeToDb(product);

            //Act
            await productService.SoftDelete(1);

            var expectedIsDeleted = true;
            var actualIsDeleted   = (await productRepo.GetByIdAsync(1)).IsDeleted;

            //Assert
            Assert.Equal(expectedIsDeleted, actualIsDeleted);
        }