Пример #1
0
        public void TestRule1_AB_Percent()
        {
            float expected = 27;

            Shop shop = new Shop();

            AddRules(ref shop);
            shop.AddProductToShoppingCart(A);
            shop.AddProductToShoppingCart(B);

            float actual = shop.GetSummaryPrice();

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void TestRule2_DE_Value()
        {
            float expected = 25.0f;

            Shop shop = new Shop();

            AddRules(ref shop);
            shop.AddProductToShoppingCart(D);
            shop.AddProductToShoppingCart(E);

            float actual = shop.GetSummaryPrice();

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void Test_SimpleShoppingCartWithoutDiscountProducts()
        {
            float expected = 13;

            Shop shop = new Shop();

            AddRules(ref shop);

            shop.AddProductToShoppingCart(A);
            shop.AddProductToShoppingCart(C);

            float actual = shop.GetSummaryPrice();

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void TestRule8_AKM_more3_Percent()
        {
            float expected = 59.54f;

            Shop shop = new Shop();

            AddRules(ref shop);
            shop.AddProductToShoppingCart(A);
            shop.AddProductToShoppingCart(K);
            shop.AddProductToShoppingCart(M);

            float actual = shop.GetSummaryPrice();

            Assert.AreEqual(expected, actual);
        }
Пример #5
0
        public void TestRule3_EFG_more3_Percent()
        {
            float expected = 66.79f;

            Shop shop = new Shop();

            AddRules(ref shop);
            shop.AddProductToShoppingCart(E);
            shop.AddProductToShoppingCart(F);
            shop.AddProductToShoppingCart(G);

            float actual = shop.GetSummaryPrice();

            Assert.AreEqual(expected, actual);
        }
Пример #6
0
        public void TestRule10_AABBA_more5_Percent_ToDollars()
        {
            float expected = 0.84f;

            Shop shop = new Shop();

            AddRules(ref shop);
            shop.AddProductToShoppingCart(A);
            shop.AddProductToShoppingCart(A);
            shop.AddProductToShoppingCart(B);
            shop.AddProductToShoppingCart(B);
            shop.AddProductToShoppingCart(A);

            CurrencyRub rub    = new CurrencyRub(shop.GetSummaryPrice());
            float       actual = (float)Math.Round(rub.Convert(rub, new CurrencyDollar()), 2);

            Assert.AreEqual(expected, actual);
        }