Beispiel #1
0
        public void CheckoutProduct_NikeProductWithRules_ReturnDiscountedPriceAsPerRule()
        {
            //Arrange
            var products = new List <Product> {
                new Product {
                    Name = "Premium Ad", Price = 379.99
                },
                new Product {
                    Name = "Premium Ad", Price = 379.99
                },
                new Product {
                    Name = "Premium Ad", Price = 379.99
                },
                new Product {
                    Name = "Premium Ad", Price = 379.99
                }
            };
            var rules = new List <Rule> {
                new Rule {
                    ProductName = "Premium Ads"
                }
            };

            //Act
            var result = AdsCheckout.PerformCheckout(products, rules);

            //Assert
            Assert.AreEqual(1519.96, result);
        }
Beispiel #2
0
        public void CheckoutProduct_DifferentProductWithRules_ReturnsTotalAmount()
        {
            // Arrange
            var products = new List <Product> {
                new Product {
                    Name = "Classic Ad", Price = 269.99
                },
                new Product {
                    Name = "Premium Ad", Price = 394.99
                },
            };
            var rules = new List <Rule> {
                new Rule {
                    ProductName = "Classic Ads"
                },
                new Rule {
                    ProductName = "Standout Ads"
                }
            };
            // Act
            var result = AdsCheckout.PerformCheckout(products, rules);

            // Assert
            Assert.AreEqual(664.98, result);
        }
Beispiel #3
0
 private static void CheckoutDefault(List <CustomerRule> fileRules)
 {
     Console.WriteLine("Total of Cart is : " + AdsCheckout.PerformCheckout(
                           new List <Product>
     {
         new ClassicAd(),
         new StandoutAd(),
         new PremiumAd()
     },
                           RuleHelper.GetRulesForCustomer("default", fileRules)
                           ));
 }
Beispiel #4
0
        public void CheckoutProduct_WithoutProduct_ReturnsZeroProduct()
        {
            // Arrange
            var products = new List <Product> {
            };
            var rules    = new List <Rule> {
            };
            // Act
            var result = AdsCheckout.PerformCheckout(products, rules);

            // Assert
            Assert.AreEqual(0, result);
        }
Beispiel #5
0
 private static void CheckoutNike(List <CustomerRule> fileRules)
 {
     Console.WriteLine("Total of cart is : " + AdsCheckout.PerformCheckout(
                           new List <Product>
     {
         new PremiumAd(),
         new PremiumAd(),
         new PremiumAd(),
         new PremiumAd()
     },
                           RuleHelper.GetRulesForCustomer("nike", fileRules)
                           ));
 }