예제 #1
0
        public static List <object[]> GetTestProducts()
        {
            // List of test args - list of products to calculate the discount for, expected discount amount,
            // and expected list of products affected or involved in the discount
            var result = new List <object[]>()
            {
                // Empty basket, total discount should be zero
                new object[] { new Product[0], 0, new Product[0] },

                // Three products, no discount here
                new object[] { new[] { ProductHelper.GetBread(), ProductHelper.GetButter(), ProductHelper.GetMilk() }, 0m, new Product[0] }
            };

            var products = new[] { ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk() };

            result.Add(new object[] { products, ProductHelper.GetMilk().Price, new[] { products[0], products[1], products[2], products[3] } });

            products = new[] { ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(),
                                                        ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetMilk(), ProductHelper.GetBread(),
                                                        ProductHelper.GetButter() };
            result.Add(new object[] { products, ProductHelper.GetMilk().Price * 2m,
                                      new[] { products[0], products[1], products[2], products[3], products[4], products[5], products[6], products[7] } });

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Data to test the total price of the items in the basket when no discounts are applied.
        /// </summary>
        /// <returns></returns>
        public static List <object[]> GetTestProductsWithTheirPricesSum() => new List <object[]>()
        {
            // Empty basket, total should be zero
            new object[] { new Product[0], 0 },

            // Three products, total should be sum of their prices
            new object[] { new[] { ProductHelper.GetBread(), ProductHelper.GetButter(), ProductHelper.GetMilk() }, 2.95m }
        };
예제 #3
0
        /// <summary>
        /// Data to test the total price of the items in the basket when total discount of 2 is applied.
        /// </summary>
        /// <returns></returns>
        public static List <object[]> GetTestProductsWithTheirPricesSumDiscountedBy2() => new List <object[]>()
        {
            // Empty basket, total discounted should be zero
            new object[] { new Product[0], 0 },

            // One product, total discounted should not be less than zero
            new object[] { new[] { ProductHelper.GetButter() }, 0m },

            // Three products, total discounted should be sum of their prices minus two
            new object[] { new[] { ProductHelper.GetBread(), ProductHelper.GetButter(), ProductHelper.GetMilk() }, 0.95m }
        };