Пример #1
0
        public void AddSingleItemToCart()
        {
            var sku   = "sku1";
            var price = 0.30M;

            var MockProductData = new ProductRepository
            {
                Products = new List <Product>
                {
                    new Product {
                        SKU = sku, Name = "Product", Price = price
                    }
                }
            };

            var MockProductDiscountData = new ProductDiscountRepository
            {
                ProductDiscounts = new List <ProductDiscount>()
            };

            var cart = new ShoppingCart(MockProductData, MockProductDiscountData);

            cart.Add(sku);

            Assert.AreEqual(cart.TotalItems, 1);
            Assert.AreEqual(cart.TotalPrice, price);
        }
Пример #2
0
        internal static void IntegrationTest()
        {
            UnitTest();

            //CatalogUrlResolvingService.Use(new CatalogUrlResolvingService()); //not yet (repo)
            DiscountCalculationService.Actual();
            DiscountService.Actual();
            ProductDiscountService.Actual();
            ProductDiscountRepository.SetupNewMock().Setup(m => m.GetAll(It.IsAny <ILocalization>())).Returns(new List <DiscountProduct>());
            OrderUpdatingService.Actual();
            OrderService.Actual();
            UrlRewritingService.Actual();
            VATCheckService.Use(new ViesVatCheckService());
            //StoreService.Actual(); // todo!
            //CountriesRepository.Use(new UwebshopApplicationCachedCountriesRepository()); // werken nog niet ivm HtppContext.Current
            //VATCountriesRepository.Use(new UwebshopApplicationCachedVATCountriesRepository());

            //ProductService.Actual(); // maybe move Localize somewhere else :'(

            StoreFromUrlDeterminationService.Actual();


            OrderDiscountService.Actual();

            UrlFormatService.Actual();
            ProductUrlService.Actual();
            CategoryCatalogUrlService.Actual();
            UrlLocalizationService.Actual();
            UrlService.Actual();

            InitializeServiceLocators();
        }
Пример #3
0
        public void AddMultipleItemsToCart()
        {
            var price = 0.30M;

            var MockProductData = new ProductRepository
            {
                Products = new List <Product>
                {
                    new Product {
                        SKU = "sku1", Name = "Product1", Price = price
                    },
                    new Product {
                        SKU = "sku2", Name = "Product2", Price = price
                    },
                    new Product {
                        SKU = "sku3", Name = "Product3", Price = price
                    }
                }
            };

            var MockProductDiscountData = new ProductDiscountRepository
            {
                ProductDiscounts = new List <ProductDiscount>()
            };

            var cart = new ShoppingCart(MockProductData, MockProductDiscountData);

            cart.Add("sku1");
            cart.Add("sku2");
            cart.Add("sku3");
            cart.Add("sku2");

            Assert.AreEqual(cart.TotalItems, 4);
            Assert.AreEqual(cart.TotalPrice, price * 4);
        }
 public ProductController(ProductRepostitory productRepostitory,
                          ProductDiscountRepository productDiscountRepository,
                          IConfiguration Configuration,
                          ProductGalleryRepository productGalleryRepository,
                          ProductPackageRepostitory productPackageRepostitory,
                          ProductGroupRepository productGroupRepository,
                          ProductFeatureRepository productFeatureRepository,
                          FeatureItemRepository featureItemRepository,
                          ProductGroupFeatureRepository productGroupFeatureRepository,
                          ProductPackageGroupRepository productPackageGroupRepository,
                          ProductPackageDetailsRepostitory productPackageDetailsRepostitory,
                          ProductUnitRepository productUnitRepository)
 {
     _productRepository         = productRepostitory;
     _productDiscountRepository = productDiscountRepository;
     configuration                     = Configuration;
     _productGalleryRepository         = productGalleryRepository;
     _productPackageRepostitory        = productPackageRepostitory;
     _productGroupRepository           = productGroupRepository;
     _productFeatureRepository         = productFeatureRepository;
     _featureItemRepository            = featureItemRepository;
     _productGroupFeatureRepository    = productGroupFeatureRepository;
     _productPackageGroupRepository    = productPackageGroupRepository;
     _productPackageDetailsRepostitory = productPackageDetailsRepostitory;
     _productUnitRepository            = productUnitRepository;
 }
 public ProductPackageRepostitory(DatabaseContext dbContext,
                                  IHostingEnvironment hostingEnvironment,
                                  ProductDiscountRepository productDiscountRepository) : base(dbContext)
 {
     _hostingEnvironment        = hostingEnvironment;
     _productDiscountRepository = productDiscountRepository;
 }
 public ProductRepostitory(DatabaseContext dbContext,
                           IHostingEnvironment hostingEnvironment,
                           ProductDiscountRepository productDiscountRepository,
                           IDbConnection connection) : base(dbContext)
 {
     _hostingEnvironment        = hostingEnvironment;
     _productDiscountRepository = productDiscountRepository;
     _connection = connection;
 }
Пример #7
0
        public static void UnitTest()
        {
            CurrentContainer = new IoCContainer();
            IO.Container     = CurrentContainer;
            SettingsService.InclVat();
            VatCalculationStrategy.OverParts();

            Logger.Mock();

            UwebshopConfiguration.UseType <UwebshopConfiguration>();            // todo no UseType? (slow)
            UwebshopRequestService.Use(MockConstructors.CreateMockUwebshopRequestService());

            OrderDiscountRepository.SetupFake();
            CategoryService.Use(MockConstructors.CreateMockEntityService <ICategoryService, Category>());
            ProductVariantService.Use(MockConstructors.CreateMockEntityService <IProductVariantService, ProductVariant>());
            CouponCodeService.Mock();

            StoreRepository.Use(new TestStoreRepository());
            CMSEntityRepository.Use(new TestCMSEntityRepository());
            CountryRepository.Use(new TestCountryRepository());
            VATCountryRepository.Use(new TestVATCountryRepository());
            OrderRepository.Mock();
            ProductDiscountRepository.Mock();
            ProductRepository.Mock();
            ProductVariantGroupRepository.Mock();
            CategoryRepository.Mock();
            ProductVariantRepository.Mock();

            CMSApplication.Use(new StubCMSApplicationNotInBackend());
            HttpContextWrapper.Mock();

            DiscountService.UseType <FakeDiscountService>();

            StoreService.Use(new TestStoreService());
            OrderService.Use(new TestOrderService());
            ProductService.Use(new TestProductService());
            CMSDocumentTypeService.Use(new StubCMSDocumentTypeService());

            OrderUpdatingService.Mock();
            OrderNumberService.Mock();
            CatalogUrlResolvingService.Mock();
            PaymentProviderService.Mock();
            StoreFromUrlDeterminationService.Mock();
            StockService.Mock();
            ApplicationCacheService.Mock();

            UwebshopRequestService.Use(new StubUwebshopRequestService());

            CurrentContainer.SetDefaultServiceFactory(new MockServiceFactory());

            ModuleFunctionality.Register(CurrentContainer);
            CurrentContainer.RegisterType <IContentTypeAliassesXmlService, StubContentTypeAliassesXmlService>();
            CurrentContainer.RegisterType <IProductVariantGroupService, ProductVariantGroupService>();

            InitializeServiceLocators();
        }
Пример #8
0
        public void AddMultipleDiscounts()
        {
            var price1         = 0.80M;
            var price2         = 0.40M;
            var price3         = 0.60M;
            var discountPrice1 = 0.70M;

            var MockProductData = new ProductRepository
            {
                Products = new List <Product>
                {
                    new Product {
                        SKU = "sku1", Name = "Product1", Price = price1
                    },
                    new Product {
                        SKU = "sku2", Name = "Product2", Price = price2
                    },
                    new Product {
                        SKU = "sku3", Name = "Product3", Price = price3
                    }
                }
            };

            var MockProductDiscountData = new ProductDiscountRepository
            {
                ProductDiscounts = new List <ProductDiscount>
                {
                    new ProductDiscount
                    {
                        SKUKeys = new List <string> {
                            "sku2", "sku2"
                        },
                        Name  = "Discount1",
                        Price = discountPrice1
                    }
                }
            };

            var cart = new ShoppingCart(MockProductData, MockProductDiscountData);

            cart.Add("sku1");
            cart.Add("sku2");
            cart.Add("sku3");
            cart.Add("sku2");
            cart.Add("sku2");
            cart.Add("sku2");

            Assert.AreEqual(cart.TotalItems, 6);
            Assert.AreEqual(cart.TotalPrice, price1 + price3 + (discountPrice1 * 2));
        }
Пример #9
0
 public UnitOfWork(HeroContext context)
 {
     _context         = context;
     Contacts         = new ContactRepository(_context);
     Users            = new UserRepository(context);
     Roles            = new RoleRepository(context);
     Orders           = new OrderRepository(context);
     OrderDetails     = new OrderDetailRepository(context);
     Products         = new ProductRepository(_context);
     Categories       = new CategoryRepository(_context);
     Sliders          = new SliderRepository(_context);
     ProductDiscounts = new ProductDiscountRepository(_context);
     Countries        = new CountryRepository(_context);
 }
 public ManageProductController(UsersAccessRepository usersAccessRepository,
                                ProductRepostitory productRepostitory,
                                ProductGroupRepository productGroupRepository,
                                ProductUnitRepository productUnitRepository,
                                ProductGroupFeatureRepository productGroupFeatureRepository,
                                ProductFeatureRepository productFeatureRepository,
                                ProductGalleryRepository productGalleryRepository,
                                FeatureRepository featureRepository,
                                ProductDiscountRepository productDiscountRepository) : base(usersAccessRepository)
 {
     _productRepostitory            = productRepostitory;
     _productGroupRepository        = productGroupRepository;
     _productUnitRepository         = productUnitRepository;
     _productGroupFeatureRepository = productGroupFeatureRepository;
     _productFeatureRepository      = productFeatureRepository;
     _productGalleryRepository      = productGalleryRepository;
     _featureRepository             = featureRepository;
     _productDiscountRepository     = productDiscountRepository;
 }
Пример #11
0
        public void AddMultipleDifferentDiscounts()
        {
            var price1         = 0.80M;
            var price2         = 0.40M;
            var price3         = 0.60M;
            var discountPrice1 = 0.75M;
            var discountPrice2 = 0.70M;

            var MockProductData = new ProductRepository
            {
                Products = new List <Product>
                {
                    new Product {
                        SKU = "sku1", Name = "Product1", Price = price1
                    },
                    new Product {
                        SKU = "sku2", Name = "Product2", Price = price2
                    },
                    new Product {
                        SKU = "sku3", Name = "Product3", Price = price3
                    }
                }
            };

            var MockProductDiscountData = new ProductDiscountRepository
            {
                ProductDiscounts = new List <ProductDiscount>
                {
                    new ProductDiscount
                    {
                        SKUKeys = new List <string> {
                            "sku2", "sku3"
                        },
                        Name  = "Discount1",
                        Price = discountPrice1
                    },
                    new ProductDiscount
                    {
                        SKUKeys = new List <string> {
                            "sku2", "sku2"
                        },
                        Name  = "Discount2",
                        Price = discountPrice2
                    }
                }
            };

            var cart = new ShoppingCart(MockProductData, MockProductDiscountData);

            cart.Add("sku1");
            cart.Add("sku2");
            cart.Add("sku3");
            cart.Add("sku2");
            cart.Add("sku2");
            cart.Add("sku2");

            foreach (var item in cart.Items)
            {
                Console.WriteLine($"{item.Name}  {item.Price}");
            }

            Assert.AreEqual(cart.TotalItems, 6);
            Assert.AreEqual(cart.TotalPrice, price1 + price2 + discountPrice1 + discountPrice2);
        }
 public ManageProductDiscountController(UsersAccessRepository usersAccessRepository
                                        , ProductDiscountRepository productDiscountRepository) : base(usersAccessRepository)
 {
     _productDiscountRepository = productDiscountRepository;
 }
 public CountDownProductVC(ProductDiscountRepository productDiscountRepository)
 {
     _productDiscountRepository = productDiscountRepository;
 }