示例#1
0
        public void ApplyDiscountTest()
        {
            StockKeepingUnit temp  = new StockKeepingUnit("Test1", 1.5F);
            StockKeepingUnit temp2 = new StockKeepingUnit("Test2", 5.0F);
            BuyItemsGetPercentageFromItemDiscountUnit target = new BuyItemsGetPercentageFromItemDiscountUnit("Test 1 discount", temp, temp2, 2, 50.0); // TODO: Initialize to an appropriate value
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp2 });                                             // TODO: Initialize to an appropriate value

            double         expected = 2.5F;                                                                                                            // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2));
        }
示例#2
0
        public void ApplyDiscountTest2()
        {
            StockKeepingUnit temp  = new StockKeepingUnit("Test1", 1.5F);
            StockKeepingUnit temp2 = new StockKeepingUnit("Test2", 5.0F);
            BuyItemsGetPercentageFromItemDiscountUnit target = new BuyItemsGetPercentageFromItemDiscountUnit("Test 1 discount", temp, temp2, 2, 50.0); // TODO: Initialize to an appropriate value
            StockKeepingUnits items = new StockKeepingUnits(new StockKeepingUnit[] { temp, temp, temp2, temp, temp, temp2, temp2 });                   // TODO: Initialize to an appropriate value

            //there should be 2 discounts on Test 2 (50% or 5, so 2 x 2.5) and the extra Test2 should be ignored.
            double         expected = 5.0F; // TODO: Initialize to an appropriate value
            DiscountResult actual   = target.ApplyDiscount(items);

            Assert.IsTrue(System.Math.Round(expected, 2) == System.Math.Round(actual.Discount, 2), string.Format("L: {0} R: {1}", expected, actual.Discount));
        }