public void GetProductInfoTest()
        {
            var ops = new ProductOperations();
            var products = ops.GetProductInfo();
            var product = products.FirstOrDefault();
            var numProducts = products.Count();

            //Validating that all information is accurate
            Assert.AreEqual(product.ProductType, "rock");
            Assert.AreEqual(product.CostPerSquareFoot, 5.00);
            Assert.AreEqual(product.LaborCostPerSquareFoot, 2.50);

            //Validating total number of products is returned
            Assert.AreEqual(numProducts, 3);
        }
Ejemplo n.º 2
0
        public void BuildOrder()
        {
            var taxOps = new TaxOperations();
            var stateTaxInfo = taxOps.GetTaxInfo();

            var prodOps = new ProductOperations();
            var productInfo = prodOps.GetProductInfo();

            var result =
                productInfo.FirstOrDefault(p => p.ProductType.ToLower() == _customerOrder.ProductInfo.ProductType.ToLower());
            var tax = stateTaxInfo.FirstOrDefault(p => p.StateAbbreviation.ToUpper() == _customerOrder.State.ToUpper());

            _customerOrder.ProductInfo.CostPerSquareFoot = result.CostPerSquareFoot;
            _customerOrder.ProductInfo.LaborCostPerSquareFoot = result.LaborCostPerSquareFoot;
            _customerOrder.TaxRate = tax.TaxRate;
            _customerOrder.MaterialCost = _customerOrder.Area * _customerOrder.ProductInfo.CostPerSquareFoot;
            _customerOrder.LaborCost = _customerOrder.Area * _customerOrder.ProductInfo.LaborCostPerSquareFoot;
            _customerOrder.Tax = (_customerOrder.MaterialCost + _customerOrder.LaborCost) * (_customerOrder.TaxRate/100);
            _customerOrder.Total = _customerOrder.MaterialCost + _customerOrder.LaborCost + _customerOrder.Tax;
        }
Ejemplo n.º 3
0
        public void GetProductType()
        {
            string input = "";

            var ops = new ProductOperations();
            var productInfo = ops.GetProductInfo();

            var products = productInfo.Select(product => product.ProductType.ToLower()).ToList();

            do
            {

                Console.Clear();
                Console.WriteLine("Product Type Options");
                Console.WriteLine("--------------------");
                Console.WriteLine();
                foreach (var product in products)
                {
                    Console.Write("{0} ", product.ToLower());
                }
                Console.WriteLine();
                Console.Write("\nEnter Product Type: ");
                input = Console.ReadLine().ToLower();

                if (products.Contains(input))
                {
                    _newOrder.ProductInfo.ProductType = input;
                    return;
                }

                Console.WriteLine();
                Console.WriteLine("That was not a valid product type.");
                Console.Write("\nPress enter to continue...");
                ErrorLogOperations.LogError(string.Format("Add Order: Invalid Product Type entered: {0}", input));
                Console.ReadLine();
            } while (true);
        }
Ejemplo n.º 4
0
        public void PromptUserForPT()
        {
            string input = "";

            var ops = new ProductOperations();
            var productInfo = ops.GetProductInfo();

            var products = productInfo.Select(product => product.ProductType.ToLower()).ToList();

            do
            {

                Console.Clear();
                Console.WriteLine("Product Type Options");
                Console.WriteLine("--------------------");
                Console.WriteLine();
                foreach (var product in products)
                {
                    Console.Write("{0} ", product.ToLower());
                }
                Console.WriteLine();
                Console.Write("\nEnter Product Type ({0}): ", _customerOrder.ProductInfo.ProductType);
                string newPT = Console.ReadLine().ToLower();

                if (products.Contains(newPT) || newPT == "")
                {
                    if (newPT == "")
                    {
                        return;
                    }
                    else
                    {
                        _customerOrder.ProductInfo.ProductType = newPT;
                        return;
                    }
                }

                Console.WriteLine();
                Console.WriteLine("That was not a valid product type.");
                Console.Write("\nPress enter to continue...");
                ErrorLogOperations.LogError(string.Format("Edit Order: Invalid Product Type entered: {0}", input));
                Console.ReadLine();
            } while (true);
        }