Exemplo n.º 1
0
        public static void GetPriceWithSpecialOffers_WithNoSpecialOffers_ReturnsOriginalPriceOfProducts()
        {
            Product p1 = new Product()
            {
                ProductId = 1, Price = 10
            };
            Product p2 = new Product()
            {
                ProductId = 2, Price = 20
            };
            Product p3 = new Product()
            {
                ProductId = 3, Price = 30
            };

            var res = SalesPriceCalculator.GetPriceWithSpecialOffers(null,
                                                                     new List <Product> {
                p1, p2, p3
            });

            using (new AssertionScope())
            {
                res.Price.Should().Be(60);
                res.ProductIds.Should().Contain(new ulong[] { 1, 2, 3 });
            }
        }
Exemplo n.º 2
0
        public static void Test4()
        {
            Product p1 = new Product()
            {
                ProductId = 1, Price = 10
            };
            Product p2 = new Product()
            {
                ProductId = 2, Price = 20
            };
            Product p3 = new Product()
            {
                ProductId = 3, Price = 30
            };
            Product p4 = new Product()
            {
                ProductId = 4, Price = 40
            };

            CombinationProduct c1 = new CombinationProduct(
                productId: 5,
                price: 15,
                subProducts: new List <ulong> {
                1, 2
            });

            CombinationProduct c2 = new CombinationProduct(
                productId: 6,
                price: 35,
                subProducts: new List <ulong> {
                2, 3
            });

            var res = SalesPriceCalculator.GetPriceWithSpecialOffers(new List <CombinationProduct>()
            {
                c1, c2
            },
                                                                     new List <Product> {
                p1, p2, p2, p3, p3, p4
            });

            using (new AssertionScope())
            {
                res.Price.Should().Be(120);
                res.ProductIds.Should().Contain(new ulong[] { 5, 6, 3, 4 });
            }
        }
Exemplo n.º 3
0
        public static void Test2()
        {
            Product p1 = new Product()
            {
                ProductId = 1, Price = 10
            };
            Product p2 = new Product()
            {
                ProductId = 2, Price = 20
            };

            CombinationProduct c1 = new CombinationProduct(
                productId: 4,
                price: 15,
                subProducts: new List <ulong> {
                1, 1
            });

            CombinationProduct c2 = new CombinationProduct(
                productId: 5,
                price: 24,
                subProducts: new List <ulong> {
                1, 2
            });

            var res = SalesPriceCalculator.GetPriceWithSpecialOffers(new List <CombinationProduct>()
            {
                c1, c2
            },
                                                                     new List <Product> {
                p1, p1, p1, p1, p2
            });

            using (new AssertionScope())
            {
                res.Price.Should().Be(49);
                res.ProductIds.Should().Contain(new ulong[] { 1, 4, 5 });
            }
        }