Exemple #1
0
 private Models.Pie MapData(Entities.Pie pie)
 {
     return(new Models.Pie
     {
         Id = pie.Id,
         Name = pie.Name,
         ShortDescription = pie.ShortDescription,
         LongDescription = pie.LongDescription,
         Price = pie.Price,
         IsPieOfTheWeek = pie.IsPieOfTheWeek,
         InStock = pie.InStock,
         ImageUrl = pie.ImageUrl,
         ThumbnailImageUrl = pie.ThumbnailImageUrl,
         CategoryId = pie.Category.Id,
         CategoryName = pie.Category.Name
     });
 }
        public ShoppingCartControllerTests()
        {
            // Arrange
            mockShoppingCartService = new Mock <IShoppingCartService>();
            mockPieService          = new Mock <IPieService>();
            mockMapper = new Mock <IMapper>();
            sut        = new ShoppingCartController(mockShoppingCartService.Object, mockPieService.Object, mockMapper.Object);

            var category1 = new Entities.Category {
                Id = 1, Name = "Category1", Description = "Category1_Description"
            };
            var category2 = new Entities.Category {
                Id = 2, Name = "Category2", Description = "Category2_Description"
            };
            var category3 = new Entities.Category {
                Id = 3, Name = "Category3", Description = "Category3_Description"
            };

            var pie1 = new Entities.Pie {
                Id = 1, Name = "Pie1", ShortDescription = "Pie1_ShortDescription", LongDescription = "Pie1_LongDescription", Price = 10.99m, IsPieOfTheWeek = true, InStock = true, ImageUrl = "Pie1_ImageUrl", ThumbnailImageUrl = "Pie1_ThumbnailImageUrl", Category = category1
            };
            var pie2 = new Entities.Pie {
                Id = 2, Name = "Pie2", ShortDescription = "Pie2_ShortDescription", LongDescription = "Pie2_LongDescription", Price = 11.50m, IsPieOfTheWeek = false, InStock = false, ImageUrl = "Pie2_ImageUrl", ThumbnailImageUrl = "Pie2_ThumbnailImageUrl", Category = category2
            };
            var pie3 = new Entities.Pie {
                Id = 3, Name = "Pie3", ShortDescription = "Pie3_ShortDescription", LongDescription = "Pie3_LongDescription", Price = 12.59m, IsPieOfTheWeek = false, InStock = true, ImageUrl = "Pie3_ImageUrl", ThumbnailImageUrl = "Pie3_ThumbnailImageUrl", Category = category3
            };
            var pie4 = new Entities.Pie {
                Id = 4, Name = "Pie4", ShortDescription = "Pie4_ShortDescription", LongDescription = "Pie4_LongDescription", Price = 15.95m, IsPieOfTheWeek = false, InStock = true, ImageUrl = "Pie4_ImageUrl", ThumbnailImageUrl = "Pie4_ThumbnailImageUrl", Category = category1
            };
            var pie5 = new Entities.Pie {
                Id = 5, Name = "Pie5", ShortDescription = "Pie5_ShortDescription", LongDescription = "Pie5_LongDescription", Price = 16.95m, IsPieOfTheWeek = true, InStock = true, ImageUrl = "Pie5_ImageUrl", ThumbnailImageUrl = "Pie5_ThumbnailImageUrl", Category = category2
            };
            var pie6 = new Entities.Pie {
                Id = 6, Name = "Pie6", ShortDescription = "Pie6_ShortDescription", LongDescription = "Pie6_LongDescription", Price = 21.40m, IsPieOfTheWeek = false, InStock = false, ImageUrl = "Pie6_ImageUrl", ThumbnailImageUrl = "Pie6_ThumbnailImageUrl", Category = category3
            };

            pies = new Entities.Pie[] { pie1, pie2, pie3, pie4, pie5, pie6 };

            shoppingCartItems = new Entities.ShoppingCartItem[]
            {
                new Entities.ShoppingCartItem {
                    Id = 1, Pie = pie1, Quantity = 1, ShoppingCartId = shoppingCartId
                },
                new Entities.ShoppingCartItem {
                    Id = 2, Pie = pie2, Quantity = 2, ShoppingCartId = shoppingCartId
                },
                new Entities.ShoppingCartItem {
                    Id = 3, Pie = pie3, Quantity = 1, ShoppingCartId = shoppingCartId
                },
                new Entities.ShoppingCartItem {
                    Id = 4, Pie = pie4, Quantity = 4, ShoppingCartId = shoppingCartId
                },
                new Entities.ShoppingCartItem {
                    Id = 5, Pie = pie5, Quantity = 1, ShoppingCartId = shoppingCartId
                },
                new Entities.ShoppingCartItem {
                    Id = 6, Pie = pie6, Quantity = 6, ShoppingCartId = shoppingCartId
                }
            };
        }