public async Task TestGetPostCodeDetailAsync() { var mocRestClient = new Mock <IPostCodeRestClient>(); var apiResult = new PostCodeDto { PostCode = "se38hn", Latitude = 1, Longitude = 1 }; var cordinates = new List <PostCodeResponseResultDto> { new PostCodeResponseResultDto { QueryPostCode = "se38hn", Result = apiResult } }; var postCodeResponse = new APIPostCodeResponseDto { Status = "200", ResponseResult = cordinates }; mocRestClient.Setup(c => c.GetPostCodeDataAsync("se38hn")) .ReturnsAsync(postCodeResponse); var postCodeProcessor = new PostCodeProcessor(_restClientMock.Object, _cacheStorageMock.Object, _configuration); var result = await postCodeProcessor.GetPostCodeDetailAsync("se38hn"); Assert.IsNotNull(result); }
public void Setup() { var mocRestClient = new Mock <IPostCodeRestClient>(); var apiResult = new PostCodeDto { PostCode = "se38hn", Latitude = 1, Longitude = 1 }; var cordinates = new List <PostCodeResponseResultDto> { new PostCodeResponseResultDto { QueryPostCode = "se38hn", Result = apiResult } }; var postCodeResponse = new APIPostCodeResponseDto { Status = "200", ResponseResult = cordinates }; mocRestClient.Setup(c => c.GetPostCodeDataAsync("se38hn")) .ReturnsAsync(postCodeResponse); _restClientMock = mocRestClient; var myConfiguration = new Dictionary <string, string> { { "IsCacheActivated", "true" }, }; _configuration = new ConfigurationBuilder() .AddInMemoryCollection(myConfiguration) .Build(); var mocCache = new Mock <ICacheStorage>(); }