public void AskState(OrderLookupResponse response) { TaxManager taxManager = TaxFactory.Create(); while (true) { Console.Clear(); Console.Write($"Enter State ({response.Order.State}): "); string state = (Console.ReadLine()).ToUpper(); TaxResponse taxResponse = taxManager.TaxRate(state); if (string.IsNullOrEmpty(state)) { ConsoleIO.DisplayOrderDetails(response.Order); return; } else { if (taxResponse.Success) { response.Order.State = taxResponse.Tax.StateAbbreviation; //set state response.Order.TaxRate = taxResponse.Tax.TaxRate; //make sure the new tax goes through ConsoleIO.DisplayOrderDetails(response.Order); break; } else { Console.WriteLine(taxResponse.Message); ConsoleIO.PressAnyKey(); continue; //Console.Clear(); } } } }
[TestCase("New York", "NY", 8.0)]//true public void TaxGetTest(string state, string abb, decimal taxi) { Tax tax = new Tax { StateName = state, StateAbbreviation = abb, TaxRate = taxi }; TaxManager manager = TaxFactory.Create(); TaxResponse response = manager.TaxRate(state); Assert.AreEqual(response.Tax.StateName, state); Assert.AreEqual(response.Tax.StateAbbreviation, abb); Assert.AreEqual(response.Tax.TaxRate, taxi); }
public void SetState(Order order) { TaxManager taxManager = TaxFactory.Create(); while (true) { Console.Clear(); Console.WriteLine("State Choices: "); foreach (Tax t in taxManager.GetTaxes()) { Console.WriteLine($"{t.StateAbbreviation},{t.StateName},Tax Rate: {t.TaxRate}"); } Console.Write($"Enter State: "); string state = (Console.ReadLine()).ToUpper(); TaxResponse taxResponse = taxManager.TaxRate(state); if (string.IsNullOrEmpty(state)) { Console.WriteLine("The entry was null or empty"); ConsoleIO.PressAnyKey(); continue; } else { if (taxResponse.Success) { order.State = taxResponse.Tax.StateAbbreviation; //set state order.TaxRate = taxResponse.Tax.TaxRate; //make sure the new tax goes through break; } else { Console.WriteLine(taxResponse.Message); ConsoleIO.PressAnyKey(); continue; //Console.Clear(); } } } }