public void WithProductCategorySetToNone_CheckCalculationWithAudio10() { var appleHeadphones = new CartItem(_productRepository) { ProductId = 1, UnitQuantity = 2 }; var appleUsbCable = new CartItem(_productRepository) { ProductId = 2, UnitQuantity = 1 }; var hPMonitor = new CartItem(_productRepository) { ProductId = 3, UnitQuantity = 1 }; var dellLaptop = new CartItem(_productRepository) { ProductId = 4, UnitQuantity = 1 }; var cart = new List <CartItem> { appleHeadphones, appleUsbCable, hPMonitor, dellLaptop }; var couponId = 1; // "AUDIO10" var calc = new ShoppingCartEngineBuilder() .AddCartItems(cart) .AddProductRepository(_productRepository) .AddCoupon(couponId) .AddCouponRepository(_couponRepository) .GetShoppingCartEngine(); var total = calc.Total(); Assert.AreEqual(1124.00m, total); }
public void WithInvalidSupplier_CheckCalculationWithLaptop5() { var appleHeadphones = new CartItem(_productRepository) { ProductId = 1, UnitQuantity = 2 }; var appleUsbCable = new CartItem(_productRepository) { ProductId = 2, UnitQuantity = 1 }; var hPMonitor = new CartItem(_productRepository) { ProductId = 3, UnitQuantity = 1 }; var dellLaptop = new CartItem(_productRepository) { ProductId = 4, UnitQuantity = 1 }; var cart = new List <CartItem> { appleHeadphones, appleUsbCable, hPMonitor, dellLaptop }; var couponId = 2; // "LAPTOP5" var calc = new ShoppingCartEngineBuilder() .AddCartItems(cart) .AddProductRepository(_productRepository) .AddCoupon(couponId) .AddCouponRepository(_couponRepository) .GetShoppingCartEngine(); var total = calc.Total(); Assert.AreEqual(1124m, total); }
public void WithDiscountPercentageBelowZero_CheckCalculationWithMinusOne() { var appleHeadphones = new CartItem(_productRepository) { ProductId = 1, UnitQuantity = 2 }; var appleUsbCable = new CartItem(_productRepository) { ProductId = 2, UnitQuantity = 1 }; var hPMonitor = new CartItem(_productRepository) { ProductId = 3, UnitQuantity = 1 }; var dellLaptop = new CartItem(_productRepository) { ProductId = 4, UnitQuantity = 1 }; var cart = new List <CartItem> { appleHeadphones, appleUsbCable, hPMonitor, dellLaptop }; var couponId = 5; // "MINUSONE" var calc = new ShoppingCartEngineBuilder() .AddCartItems(cart) .AddProductRepository(_productRepository) .AddCoupon(couponId) .AddCouponRepository(_couponRepository) .GetShoppingCartEngine(); var total = calc.Total(); Assert.AreEqual(1124m, total); }
public void WithNoCart_CheckExceptionIsThrown() { var calc = new ShoppingCartEngineBuilder() .AddProductRepository(_productRepository) .GetShoppingCartEngine(); var ex = Assert.Throws <ArgumentNullException>(() => calc.Total()); Assert.That(ex.ParamName, Is.EqualTo("cartItems")); }
public void WithNoRepository_CheckExceptionIsThrown() { var carItem1 = new CartItem(_productRepository) { ProductId = 1, UnitQuantity = 1 }; var cart = new List <CartItem> { carItem1 }; var calc = new ShoppingCartEngineBuilder() .AddCartItems(cart) .GetShoppingCartEngine(); var ex = Assert.Throws <ArgumentNullException>(() => calc.Total()); Assert.That(ex.ParamName, Is.EqualTo("productRepository")); }
public void WithOneItem_CheckCalculation() { var carItem1 = new CartItem(_productRepository) { ProductId = 1, UnitQuantity = 1 }; var cart = new List <CartItem> { carItem1 }; var calc = new ShoppingCartEngineBuilder() .AddCartItems(cart) .AddProductRepository(_productRepository) .GetShoppingCartEngine(); var total = calc.Total(); Assert.AreEqual(11, total); }