private object DummyEcommerceMethod2() { SKUInfo sku = null; IOrderRepository orderRepository = null; int orderId = 0; //DocSection:DisplayCatalogDiscounts // Initializes the needed services ShoppingService shoppingService = new ShoppingService(); PricingService pricingService = new PricingService(); // Gets the current shopping cart ShoppingCart shoppingCart = shoppingService.GetCurrentShoppingCart(); // Calculates prices for the specified product ProductPrice price = pricingService.CalculatePrice(sku, shoppingCart); // Gets the catalog discount decimal catalogDiscount = price.Discount; //EndDocSection:DisplayCatalogDiscounts //DocSection:DisplayOrderList // Gets the current customer Customer currentCustomer = shoppingService.GetCurrentCustomer(); // If the customer does not exist, returns error 404 if (currentCustomer == null) { return(HttpNotFound()); } // Creates a view model representing a collection of the customer's orders OrdersViewModel model = new OrdersViewModel() { Orders = orderRepository.GetByCustomerId(currentCustomer.ID) }; //EndDocSection:DisplayOrderList //DocSection:ReorderExistingOrder // Gets the order based on its ID Order order = orderRepository.GetById(orderId); // Gets the current visitor's shopping cart ShoppingCart cart = shoppingService.GetCurrentShoppingCart(); // Loops through the items in the order and adds them to the shopping cart foreach (OrderItem item in order.OrderItems) { cart.AddItem(item.SKUID, item.Units); } // Evaluates the shopping cart cart.Evaluate(); // Saves the shopping cart cart.Save(); //EndDocSection:ReorderExistingOrder return(null); }
public void PriceCalculatedWithoutTaxesDiscounts(string skuName, double skuPrice, double listPrice, decimal expectedPrice, decimal expectedListPrice, decimal expectedDiscount, decimal expectedtax) { var cart = CreateEmptyShoppingCartWithBillingAddress(); var sku = CreateSKUInfo(skuPrice, listPrice, skuName); var calculatedPrice = mPricingService.CalculatePrice(sku, cart, false, false); var expectedResult = new ProductPrice { Discount = expectedDiscount, ListPrice = expectedListPrice, Price = expectedPrice, Tax = expectedtax }; AssertPrice(calculatedPrice, expectedResult); }
public void CalculatePrice_WithClassDataHasValidPeriods_ResultShouldBeCorrect(PriceTestCases testCase) { _mockedPricingRepository.Setup(x => x.GetPricings()).Returns(_pricingFixtureData.MockedPricings); var pricingSerice = new PricingService(_mockedPricingRepository.Object); var result = pricingSerice.CalculatePrice(testCase.CheckIn, testCase.CheckOut, testCase.Price); Assert.Equal(testCase.ExpPrice, result); }
public void CalculatePrice_HasValidPeriods_ResultShouldBeCorrect(string checkIn, string checkOut, decimal price, decimal expResult) { _mockedPricingRepository.Setup(x => x.GetPricings()).Returns(_pricingFixtureData.MockedPricings); var pricingSerice = new PricingService(_mockedPricingRepository.Object); var result = pricingSerice.CalculatePrice(DateTime.Parse(checkIn), DateTime.Parse(checkOut), price); Assert.Equal(expResult, result); }
public void CalculatePrice_TestCasesAreDefinedAsMemberData_ResultShouldBeCorrect(DateTime checkIn, DateTime checkOut, decimal price, decimal expectedResult) { //Arrange _pricingRepository.Setup(x => x.GetPricings()).Returns(_pricingFixtureData.MockedPricings); //Act var pricingService = new PricingService(_pricingRepository.Object); var result = pricingService.CalculatePrice(checkIn, checkOut, price); //Assert Assert.Equal(expectedResult, result); }