public async Task GetRateAsyncTest() { var taxCalculatorMock = new TaxCalculatorMock(); var taxService = new TaxServiceWorker(taxCalculatorMock); var serviceRate = await taxService.GetRate("90404", "US", "Santa Monica"); var calculatorRate = await taxCalculatorMock.GetRateAsync("90404", "US", "Santa Monica"); Assert.IsTrue(serviceRate.IsDeepEqual(calculatorRate)); }
public async Task <IActionResult> GetRate() { // This most definetely is not the best way to make a form. I eneded up using this way because I thought this challange was more on the // Tax service itself. Had it been more on the client I would have focused on trying to use a Javascript library to make it work a little nicer. string country = null; if (Request.Query["Country"] != "") { country = Request.Query["Country"]; } string city = null; if (Request.Query["City"] != "") { city = Request.Query["City"]; } string street = null; if (Request.Query["Street"] != "") { street = Request.Query["Street"]; } var serviceRate = await _taxService.GetRate(Request.Query["Zip"], country, city, street); // Instead of doing something like this I would most probably implement Automapper var rate = new Rate() { City = serviceRate.city, CityRate = serviceRate.city_rate, CombinedDistrictRate = serviceRate.combined_district_rate, CombinedRate = serviceRate.combined_rate, Country = serviceRate.country, CountryRate = serviceRate.country_rate, County = serviceRate.county, CountyRate = serviceRate.county_rate, FreightTaxable = serviceRate.freight_taxable, State = serviceRate.state, StateRate = serviceRate.state_rate, Zip = serviceRate.zip }; return(View("Rate", rate)); }