Exemple #1
0
        static void Main(string[] args)
        {
            // Create an instance of Interface
            InterfaceSKU SKU = new SKU();

            List <ProductDetails> products = new List <ProductDetails>();

            Console.WriteLine("total number of items in the order");
            int a = Convert.ToInt32(Console.ReadLine());

            while (a > 0)
            {
                Console.WriteLine("enter the type of product:A,B,C or D");
                string type = Console.ReadLine();
                Console.WriteLine("enter the quantity of the product type");
                int            count   = Convert.ToInt32(Console.ReadLine());
                ProductDetails product = new ProductDetails();
                product.ProductType     = type;
                product.ProductQuantity = count;
                product.ProductPrice    = SKU.GetPriceByType(product);
                products.Add(product);
                a = a - count;
            }

            int totalPrice = SKU.GetTotal(products);

            Console.WriteLine(totalPrice);
            Console.ReadLine();
        }
        public async Task TestSKU3()
        {
            //Arrange

            InterfaceSKU sku = new SKU();

            // We will basically test the service layer by mocking objects from out test class
            var products = new List <ProductDetails>();

            ProductDetails productA = new ProductDetails();

            productA.ProductType     = "A";
            productA.ProductPrice    = 50;
            productA.ProductQuantity = 3;
            products.Add(productA);

            ProductDetails productB = new ProductDetails();

            productB.ProductType     = "B";
            productB.ProductPrice    = 30;
            productB.ProductQuantity = 5;
            products.Add(productB);

            ProductDetails productC = new ProductDetails();

            productC.ProductType     = "C";
            productC.ProductPrice    = 20;
            productC.ProductQuantity = 1;
            products.Add(productC);

            ProductDetails productD = new ProductDetails();

            productD.ProductType     = "D";
            productD.ProductPrice    = 15;
            productD.ProductQuantity = 1;
            products.Add(productD);

            int total = 280;

            // ACT

            var response = sku.GetTotal(products);

            // ASSERT

            Assert.True(response == total);
        }