Exemplo n.º 1
0
        public async Task AddCustomCakeImg_WithDuplicateCakeName_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 model1 = new CustomCakeImgViewModel
            {
                Side = "White Cigarettes",
                Top  = "Habana",
                Name = "Habana" + " " + "White Cigarettes",
                Img  = "https://res.cloudinary.com/cakeit/image/upload/v1545083551/Top_Habana_WhiteCigarettes.png"
            };

            CustomCakeImgViewModel model2 = new CustomCakeImgViewModel
            {
                Side = "White Cigarettes",
                Top  = "Habana",
                Name = "Habana" + " " + "White Cigarettes",
                Img  = "https://res.cloudinary.com/cakeit/image/upload/v1545083551/Top_Habana_WhiteCigarettes.png"
            };
            await service.AddCustomCakeImg(model1);

            //Act

            //Assert
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.AddCustomCakeImg(model2));
        }
Exemplo n.º 2
0
        private async Task SeedCustomCakeImg(CakeItDbContext 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);

            CustomCakeImgViewModel model1 = new CustomCakeImgViewModel
            {
                Side = "White Cigarettes",
                Top  = "Habana",
                Name = "Habana" + " " + "White Cigarettes",
                Img  = "https://someurl.bg"
            };

            await service.AddCustomCakeImg(model1);

            CustomCakeImgViewModel model2 = new CustomCakeImgViewModel
            {
                Side = "Dark Cigarettes",
                Top  = "Meksiko",
                Name = "Meksiko" + " " + "Dark Cigarettes",
                Img  = "https://otherurl.bg"
            };

            await service.AddCustomCakeImg(model2);

            await repo.SaveChangesAsync();
        }
Exemplo n.º 3
0
        public async Task AddCustomCakeImg_ShouldAddDataToCustomCakeImgTable()
        {
            //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 model = new CustomCakeImgViewModel
            {
                Side = "White Cigarettes",
                Top  = "Habana",
                Name = "Habana" + " " + "White Cigarettes",
                Img  = "https://res.cloudinary.com/cakeit/image/upload/v1545083551/Top_Habana_WhiteCigarettes.png"
            };

            //Act
            await service.AddCustomCakeImg(model);

            var expected = "Habana White Cigarettes";
            var actual   = repo.All().First().Name;

            //Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 4
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));
        }