public async Task <ActionResult <float> > GetTaxRate(string regNo) { var query = new TaxByRegNo(regNo); var rate = await query.Execute(_apiSource); return(Ok(rate)); }
public async Task IntegrationTest(string regNo) { ///// // Expecting result -1 since the api url is not valid. ///// var services = new ServiceCollection().AddHttpClient().BuildServiceProvider(); var apiDbAccess = new ApiDataAccess(services.GetService <IHttpClientFactory>()); var sut = new TaxByRegNo(regNo); var result = await sut.Execute(apiDbAccess); result.Should().BeOfType(typeof(float)); }
public async Task ShouldReturnNotNull() { var apiDatAccess = Substitute.For <IApiDataAccess>(); apiDatAccess .Request(Arg.Any <HttpRequestMessage>()) .Returns(Task.FromResult( new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("5000") })); var sut = new TaxByRegNo("GLW975"); var taxRate = await sut.Execute(apiDatAccess); taxRate.Should().Be(5000f); }