Esempio n. 1
0
        public void PriceStepsDefinedInRandomOrder_PriceIsCorrect()
        {
            var item = new ItemWithPriceSteps('A');

            item.AddPriceStep(10, 1);
            item.AddPriceStep(1, 3);
            item.AddPriceStep(5, 2);
            sm.Add(item);
            AssertPrice("AAAAA", 5 * 2);
            AssertPrice("AAAAAAAAAAAA", 12 * 1);
        }
Esempio n. 2
0
        public void ManyIsCheaper()
        {
            var item = new ItemWithPriceSteps('A');

            item.AddPriceStep(1, 3);
            item.AddPriceStep(5, 2);
            item.AddPriceStep(10, 1);
            sm.Add(item);
            AssertPrice("A", 3);
            AssertPrice("AA", 2 * 3);
            AssertPrice("AAAAA", 5 * 2);
            AssertPrice("AAAAAA", 6 * 2);
            AssertPrice("AAAAAAAAAA", 10 * 1);
            AssertPrice("AAAAAAAAAAAA", 12 * 1);
        }
Esempio n. 3
0
        public void ManyItemsSomeWithPriceSteps_PriceIsCorrect()
        {
            sm.Add('A', 2);
            var itemB = new ItemWithPriceSteps('B');

            itemB.AddPriceStep(1, 3);
            itemB.AddPriceStep(3, 2);
            sm.Add(itemB);
            var itemC = new ItemWithPriceSteps('C');

            itemC.AddPriceStep(1, 10);
            itemC.AddPriceStep(5, 5);
            sm.Add(itemC);
            AssertPrice("ABACCBAABB", 4 * 2 + 4 * 2 + 2 * 10);
            AssertPrice("BBCCCCCC", 2 * 3 + 6 * 5);
        }