Ejemplo n.º 1
0
        public async Task AssignImgAndPrice_WithInvalidSide_ShouldThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedCustomCakeImg(db);

            var repo = new Repository <CustomCakeImg>(db);
            var mock = new Mock <ILogger <CustomCakeService> >();
            ILogger <CustomCakeService> logger = mock.Object;
            var service = new CustomCakeService(null, repo, this.Mapper, logger);

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

            //Act

            //Assert
            Assert.Throws <NullReferenceException>(() => service.AssignImgAndPrice(model));
        }
Ejemplo n.º 2
0
        public async Task AssignImgAndPrice_ShouldReturnModelWithPriceAndJmg()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedCustomCakeImg(db);

            var repo = new Repository <CustomCakeImg>(db);
            var mock = new Mock <ILogger <CustomCakeService> >();
            ILogger <CustomCakeService> logger = mock.Object;
            var service = new CustomCakeService(null, repo, this.Mapper, logger);

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

            //Act
            var result = service.AssignImgAndPrice(model);

            var expectedPrice = 6 * 2.75m;
            var actualPrice   = result.Price;

            //Assert
            Assert.Equal(expectedPrice, actualPrice);
            Assert.NotNull(result.Img);
        }
Ejemplo n.º 3
0
        public async Task AssignImgAndPrice_WhithInvalidImgUrn_ShouldThrow()
        {
            //Arrange
            var db = this.SetDb();

            var repo = new Repository <CustomCakeImg>(db);
            var mock = new Mock <ILogger <CustomCakeService> >();
            ILogger <CustomCakeService> logger = mock.Object;
            var service = new CustomCakeService(null, repo, this.Mapper, logger);

            CustomCakeImgViewModel imgModel = new CustomCakeImgViewModel
            {
                Side = "White Cigarettes",
                Top  = "Habana",
                Name = "Habana" + " " + "White Cigarettes",
                Img  = "null"
            };

            await service.AddCustomCakeImg(imgModel);

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

            //Act

            //Assert
            Assert.Throws <InvalidOperationException>(() => service.AssignImgAndPrice(model));
        }