public void ShoppingCartWithDiscountWithFixedPriceBulkDiscountedLineItem2Test() { // arrange ShoppingCart shoppingCart = new ShoppingCart { HasCoupon = true, CouponTotalPriceThreshold = 10.00m, CouponDiscount = 1.00m }; LineItem lineItem = new FixedPriceLineItem { ProductId = 1, Name = "Cheerios (non GMO)", UnitPrice = 2.00m, Quantity = 10, IsDiscounted = true, DiscountThreshold = 4 }; shoppingCart.Add(lineItem); //act decimal actualTotalPrice = shoppingCart.GetTotalPrice(); // assert const decimal expectedTotalPrice = 15.00m; Assert.AreEqual(expectedTotalPrice, actualTotalPrice); }
public void ShoppingCartWithOneByWeightPriceLineItemTest() { // arrange ShoppingCart shoppingCart = new ShoppingCart { HasCoupon = false, CouponTotalPriceThreshold = 10.00m, CouponDiscount = 1.00m }; LineItem lineItem = new ByWeightPriceLineItem { ProductId = 1, Name = "Apples", WeightInPounds = 2.00, PricePerPound = 2.00m }; shoppingCart.Add(lineItem); //act decimal actualTotalPrice = shoppingCart.GetTotalPrice(); // assert const decimal expectedTotalPrice = 4.00m; Assert.AreEqual(expectedTotalPrice, actualTotalPrice); }
public void ShoppingCartWithMixedLineItemsTest() { // arrange ShoppingCart shoppingCart = new ShoppingCart { HasCoupon = true, CouponTotalPriceThreshold = 10.00m, CouponDiscount = 1.00m }; List<LineItem> lineItemList = new List<LineItem> { // Fixed price line items new FixedPriceLineItem { ProductId = 1, Name = "Cheerios (non GMO)", UnitPrice = 2.00m, Quantity = 3, IsDiscounted = true, DiscountThreshold = 2 }, new FixedPriceLineItem { ProductId = 2, Name = "Milk", UnitPrice = 3.00m, Quantity = 2, IsDiscounted = false }, // By weight line items new ByWeightPriceLineItem { ProductId = 3, Name = "Apples", PricePerPound = 1.00m, WeightInPounds = 1.75 }, new ByWeightPriceLineItem { ProductId = 4, Name = "Oranges", PricePerPound = 2.00m, WeightInPounds = 1.50 } }; shoppingCart.Add(lineItemList); //act decimal actualTotalPrice = shoppingCart.GetTotalPrice(); // assert const decimal expectedTotalPrice = 13.75m; Assert.AreEqual(expectedTotalPrice, actualTotalPrice); }
public void EmptyShoppingCartHasZeroTotalPriceTest() { // arrange ShoppingCart shoppingCart = new ShoppingCart { HasCoupon = false, CouponTotalPriceThreshold = 10.00m, CouponDiscount = 1.00m }; //act decimal actualTotalPrice = shoppingCart.GetTotalPrice(); // assert const decimal expectedTotalPrice = 0m; Assert.AreEqual(expectedTotalPrice, actualTotalPrice); }
public void ShoppingCartWithTwoByWeightPriceLineItems2Test() { // arrange ShoppingCart shoppingCart = new ShoppingCart { HasCoupon = false, CouponTotalPriceThreshold = 10.00m, CouponDiscount = 1.00m }; List<ByWeightPriceLineItem> byWeightPriceLineItemList = new List<ByWeightPriceLineItem> { new ByWeightPriceLineItem(productId : 1, name : "Apples", weightInPounds : 2.00, pricePerPound : 2.00m), new ByWeightPriceLineItem(productId : 1, name : "Apples", weightInPounds : 4.00, pricePerPound : 2.00m) }; shoppingCart.Add(byWeightPriceLineItemList); //act decimal actualTotalPrice = shoppingCart.GetTotalPrice(); // assert const decimal expectedTotalPrice = 12.00m; Assert.AreEqual(expectedTotalPrice, actualTotalPrice); }
public void ShoppingCartWithMultipleFixedPriceLineItems1Test() { // arrange ShoppingCart shoppingCart = new ShoppingCart { HasCoupon = false, CouponTotalPriceThreshold = 10.00m, CouponDiscount = 1.00m }; List<LineItem> lineItemList = new List<LineItem> { new FixedPriceLineItem { ProductId = 1, Name = "Cheerios (non GMO)", UnitPrice = 2.00m, Quantity = 1, IsDiscounted = false }, new FixedPriceLineItem { ProductId = 1, Name = "Cheerios (non GMO)", UnitPrice = 2.00m, Quantity = 1, IsDiscounted = false }, new FixedPriceLineItem { ProductId = 1, Name = "Cheerios (non GMO)", UnitPrice = 2.00m, Quantity = 1, IsDiscounted = false }, new FixedPriceLineItem { ProductId = 1, Name = "Cheerios (non GMO)", UnitPrice = 2.00m, Quantity = 1, IsDiscounted = false } }; shoppingCart.Add(lineItemList); //act decimal actualTotalPrice = shoppingCart.GetTotalPrice(); // assert const decimal expectedTotalPrice = 8.00m; Assert.AreEqual(expectedTotalPrice, actualTotalPrice); }
public void ShoppingCartWithMultipleFixedPriceLineItems2Test() { // arrange ShoppingCart shoppingCart = new ShoppingCart { HasCoupon = false, CouponTotalPriceThreshold = 10.00m, CouponDiscount = 1.00m }; List<LineItem> lineItemList = new List<LineItem> { new FixedPriceLineItem(productId : 1, name : "Cheerios (non GMO)", unitPrice : 2.00m, quantity : 1,isDiscounted : false, discountThreshold : 3), new FixedPriceLineItem(productId : 1, name : "Cheerios (non GMO)", unitPrice : 2.00m, quantity : 1, isDiscounted : false, discountThreshold : 3), new FixedPriceLineItem(productId : 1, name : "Cheerios (non GMO)", unitPrice : 2.00m, quantity : 1, isDiscounted : false, discountThreshold : 3), new FixedPriceLineItem(productId : 1, name : "Cheerios (non GMO)", unitPrice : 2.00m, quantity : 1, isDiscounted : false, discountThreshold : 3) }; shoppingCart.Add(lineItemList); //act decimal actualTotalPrice = shoppingCart.GetTotalPrice(); // assert const decimal expectedTotalPrice = 8.00m; Assert.AreEqual(expectedTotalPrice, actualTotalPrice); }