コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }