public void ApplyDiscountTest() { StockKeepingUnit temp = new StockKeepingUnit("Test1", 1.5); BuyItemsLessPercentageDiscountUnit target = new BuyItemsLessPercentageDiscountUnit("Test 1 discount", temp, 1, 10.0); // TODO: Initialize to an appropriate value StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp }); // TODO: Initialize to an appropriate value double expected = 0.3F; // TODO: Initialize to an appropriate value DiscountResult actual = target.ApplyDiscount(items); Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2)); }
public void ApplyDiscountTest2() { StockKeepingUnit temp = new StockKeepingUnit("Test1", 1.5); BuyItemsLessPercentageDiscountUnit target = new BuyItemsLessPercentageDiscountUnit("Test 1 discount", temp, 2, 20.00F); // TODO: Initialize to an appropriate value StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp }); // TODO: Initialize to an appropriate value double expected = 0.3; // TODO: Initialize to an appropriate value DiscountResult actual = target.ApplyDiscount(items); //Even though these were actually equal, precision screwed up the test.... *sigh* Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2)); }
public void ApplyDiscountTest3() { StockKeepingUnit temp = new StockKeepingUnit("Test1", 1.5); BuyItemsLessPercentageDiscountUnit target = new BuyItemsLessPercentageDiscountUnit("Test 1 discount", temp, 2, 50.00F); // TODO: Initialize to an appropriate value //this should match 2 offers, should ignore the extra item StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp, temp, temp, temp, temp }); // TODO: Initialize to an appropriate value double expected = 1.5F; // TODO: Initialize to an appropriate value DiscountResult actual = target.ApplyDiscount(items); Assert.AreEqual <double>(expected, actual.Discount); }
public void BuyItemsLessPercentageDiscountUnitConstructorTest() { string name = "Test"; // TODO: Initialize to an appropriate value StockKeepingUnit target1 = new StockKeepingUnit("Test1", 1.5); // TODO: Initialize to an appropriate value int targetCount = 1; // TODO: Initialize to an appropriate value double percentage = 1.0F; // TODO: Initialize to an appropriate value BuyItemsLessPercentageDiscountUnit target = new BuyItemsLessPercentageDiscountUnit(name, target1, targetCount, percentage); Assert.IsNotNull(target); Assert.AreEqual(name, target.Name); Assert.AreEqual(name, target.Name); Assert.AreEqual(targetCount, target.TargetLevel); Assert.AreEqual(percentage, target.Discount); }