예제 #1
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();
        }
 public RetailCalculatorService(
     PriceCalculationService calculator,
     DiscountCalculationService discountCalculator,
     TaxCalculationService taxCalculator)
 {
     Calculator         = calculator;
     DiscountCalculator = discountCalculator;
     TaxCalculator      = taxCalculator;
 }
        public void Discount()
        {
            var expected    = 0.03f;
            var dicountList = new List <DiscountRange>
            {
                new DiscountRange {
                    Amount = 1, Discount = 0.01f
                },
                new DiscountRange {
                    Amount = 2, Discount = 0.03f
                },
            };
            var sut = new DiscountCalculationService(dicountList);

            Assert.Equal(expected, sut.FigureDiscount(4));
        }
예제 #4
0
        public IActionResult CalculateCart()
        {
            Dictionary <string, string> cartList           = new Dictionary <string, string>();
            DiscountCalculationService  calculationService = new DiscountCalculationService();
            ProductService product     = new ProductService();
            var            productList = product.PopulateProductCartItems();

            //TODO : Lame implementation, product cart discount calculation must be real-time when cart item changes.
            for (int i = 0; i < 3; i++)
            {
                cartList.Add(Request.Form["ProductId"].ToString().Split(',')[i], Request.Form["CartCount"].ToString().Split(',')[i]);
            }

            foreach (var productItem in productList)
            {
                productItem.CartCount = int.Parse(cartList.FirstOrDefault(x => x.Key == productItem.Id.ToString()).Value);
            }

            var calculatedCartItems = calculationService.CalculateDiscountsForProducts(productList);

            return(View("Index", calculatedCartItems));
        }
        public void Choose_Should_Return_Draft()
        {
            using (var mock = AutoMock.GetLoose())
            {
                var tenantIdString  = Guid.NewGuid().ToString();
                var offerRepository = new InMemoryOfferRepository();
                mock.Provide <IOfferRepository>(offerRepository);
                var draftRepository = new InMemoryDraftRepository();
                mock.Provide <IDraftRepository>(draftRepository);
                mock.Mock <ICustomerRepository>().Setup(_ => _.Get(It.IsAny <CustomerId>())).Returns(new Customer(CustomerId.From(tenantIdString), 1));
                var discountCalculationService = new DiscountCalculationService();
                var discountService            = new DiscountService(mock.Create <ICustomerRepository>(), discountCalculationService);
                mock.Provide <IDiscountService>(discountService);
                var sut     = mock.Create <OfferService>();
                var offerId = CreateSampleOffer(mock);

                var draftId = sut.Choose(offerId.ToString(), tenantIdString, DateTime.Now.AddDays(-10), DateTime.Now.AddDays(10));

                var draft = draftRepository.Get(draftId);
                draft.Should().NotBeNull();
                draft.Id.Should().BeEquivalentTo(draftId);
            }
        }
 public DiscountService(ICustomerRepository customerRepository, DiscountCalculationService discountCalculationService)
 {
     _customerRepository         = customerRepository;
     _discountCalculationService = discountCalculationService;
 }