public async Task ValidExternalAddressResponse() { IOptionsSnapshot <ApplicationConfiguration> options = A.Fake <IOptionsSnapshot <ApplicationConfiguration> >(); A.CallTo(() => options.Value).Returns(CreateValidApplicationConfiguration()); IExternalAddressClient client = new ExternalAddressClient(options, _httpClient); _httpTest.RespondWith("100.100.100.100"); Result <IExternalAddressResponse> response = await client.GetAsync(new CancellationToken()); Assert.True(response.IsSuccess); Assert.NotNull(response.ValueOrDefault); }
public async Task InvalidExternalAddressResponses() { IOptionsSnapshot <ApplicationConfiguration> options = A.Fake <IOptionsSnapshot <ApplicationConfiguration> >(); A.CallTo(() => options.Value).Returns(CreateValidApplicationConfiguration()); IExternalAddressClient client = new ExternalAddressClient(options, _httpClient); _httpTest.RespondWith(string.Empty); _httpTest.RespondWith("Invalid text"); _httpTest.RespondWith("Not Found", 404); Result <IExternalAddressResponse> response = await client.GetAsync(new CancellationToken()); Assert.True(response.IsFailed); Assert.Null(response.ValueOrDefault); }