Пример #1
0
 public AnonymousCartController(IAnonymousCartService anonymousCartService)
 {
     this.anonymousCartService = anonymousCartService;
 }
        public void SetUp()
        {
            var mapperConfiguration = new MapperConfiguration(new MappingProfile());

            mapper = new Mapper(mapperConfiguration);

            #region Seed data
            products = new List <Product>()
            {
                new Product()
                {
                    Id          = 1,
                    WebsiteId   = 1,
                    CategoryId  = 2,
                    Name        = "Product Sub Category 1",
                    ProductCode = "Product01",
                    Quantity    = 5
                },
                new Product()
                {
                    Id          = 2,
                    WebsiteId   = 1,
                    CategoryId  = 2,
                    Name        = "Product Sub Category 2",
                    ProductCode = "Product02",
                    Quantity    = 10
                }
                ,
                new Product()
                {
                    Id          = 3,
                    WebsiteId   = 1,
                    CategoryId  = 2,
                    Name        = "Product Sub Category 2",
                    ProductCode = "Product03",
                    Quantity    = 10
                }
            };

            identityCode = Guid.NewGuid().ToString();

            anonymousCarts = new List <AnonymousCart>
            {
                new AnonymousCart
                {
                    Id           = 1,
                    WebsiteId    = 1,
                    IdentityCode = identityCode,
                    ProductId    = 1,
                    Quantity     = 1
                },
                new AnonymousCart
                {
                    Id           = 2,
                    WebsiteId    = 1,
                    IdentityCode = identityCode,
                    ProductId    = 2,
                    Quantity     = 2
                }
            };
            #endregion

            //Build company service with unit of work
            anonymousCartServiceBuilder = new AnonymousCartServiceBuilder()
                                          .WithAnonymousCartRepositoryMock(anonymousCarts)
                                          .WithProductRepositoryMock(products)
                                          .WithUnitOfWorkSetup();
            anonymousCartService = anonymousCartServiceBuilder.Build();
        }