Esempio n. 1
0
        public async Task GetOrderedProductListAysnc_Scenario2_ShouldReturn_LeastTrolleyCost(int qtyA, int qtyB, decimal expectedOutput)
        {
            var request = new CustomerTrolleyRequest();

            request.Products = new List <TrolleyProduct>
            {
                new TrolleyProduct {
                    Name = "A", Price = 10
                },
                new TrolleyProduct {
                    Name = "B", Price = 10
                }
            };

            request.Specials = new List <Special> {
                new Special
                {
                    Quantities = new List <ProductQuantities> {
                        new ProductQuantities {
                            Name = "A", Quantity = qtyA
                        },
                        new ProductQuantities {
                            Name = "B", Quantity = 0
                        }
                    },
                    Total = 10
                },
                new Special
                {
                    Quantities = new List <ProductQuantities> {
                        new ProductQuantities {
                            Name = "A", Quantity = 0
                        },
                        new ProductQuantities {
                            Name = "B", Quantity = qtyB
                        }
                    },
                    Total = 15
                }
            };

            request.Quantities = new List <ProductQuantities> {
                new ProductQuantities {
                    Name = "A", Quantity = qtyA
                },
                new ProductQuantities {
                    Name = "B", Quantity = qtyB
                }
            };

            var result = await ShoppingService.GetLowestTrolleyTotalAsync(request);

            Assert.That(result == expectedOutput);
        }