コード例 #1
0
        public void GetTaxInfoTest()
        {
            var ops = new TaxOperations();
            var taxList = ops.GetTaxInfo();
            var numStates = taxList.Count;

            var state = taxList.FirstOrDefault(s => s.StateAbbreviation == "CA");

            //Validating that all information is accurate
            Assert.AreEqual(state.StateName, "California");
            Assert.AreEqual(state.TaxRate, 7.25);

            //Validating total number of states is returned
            Assert.AreEqual(numStates, 3);
        }
コード例 #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;
        }
コード例 #3
0
ファイル: AddOrder.cs プロジェクト: mdrozda46/FlooringProgram
        public void GetCustomerState()
        {
            string input = "";

            var ops = new TaxOperations();
            var stateTaxInfo = ops.GetTaxInfo();

            var states = stateTaxInfo.Select(state => state.StateAbbreviation).ToList();

            do
            {
                Console.Clear();
                Console.WriteLine("Customer State Options");
                Console.WriteLine("----------------------");
                Console.WriteLine();
                foreach (var state in states)
                {
                    Console.Write("{0} ", state);
                }
                Console.WriteLine();
                Console.Write("\nEnter Customer State: ");

                input = Console.ReadLine().ToUpper();

                if (states.Contains(input))
                {
                    _newOrder.State = input;
                    return;
                }

                Console.WriteLine();
                Console.WriteLine("That was not a valid state name.");
                Console.Write("\nPress enter to continue...");
                ErrorLogOperations.LogError(string.Format("Add Order: Invalid State entered: {0}", input));
                Console.ReadLine();
            } while (true);
        }
コード例 #4
0
        public void PromptUserForState()
        {
            string input = "";

            var ops = new TaxOperations();
            var stateTaxInfo = ops.GetTaxInfo();

            var states = stateTaxInfo.Select(state => state.StateAbbreviation).ToList();

            do
            {
                Console.Clear();
                Console.WriteLine("Customer State Options");
                Console.WriteLine("----------------------");
                Console.WriteLine();
                foreach (var state in states)
                {
                    Console.Write("{0} ", state);
                }
                Console.WriteLine();
                Console.Write("\nEnter State ({0}): ", _customerOrder.State);
                string newState = Console.ReadLine().ToUpper();

                if (states.Contains(newState) || newState == "")
                {
                    if (newState == "")
                    {
                        return;
                    }
                    else
                    {
                        _customerOrder.State = newState;
                        return;
                    }
                }

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