public async Task SuccessFalseIfUnableToGetDescription(HttpStatusCode httpStatusCode) { var pokemonName = "notExits"; var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{_baseUri}{pokemonName}/").Respond(httpStatusCode); var sut = new PokeAPIClient(mockHttp.ToHttpClient()); var response = await sut.GetPokemonDescriptionAsync(pokemonName); Assert.False(response.IsSuccess); }
public async Task ShouldRetrievePokemonDescription(string pokemonName, string expectedDescription) { var json = ReadEmbeddedResource($"{pokemonName}-pokemon-species.json"); var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{_baseUri}{pokemonName}/").Respond("application/json", json); var sut = new PokeAPIClient(mockHttp.ToHttpClient()); var response = await sut.GetPokemonDescriptionAsync(pokemonName); Assert.True(response.IsSuccess); Assert.Equal(expectedDescription, response.Value); }