Exemplo n.º 1
0
        private void PrepareMockResponseHandler(MockResponseHandler mockResponseHandler, int number)
        {
            var uri          = _baseUri + number + "/" + _infoJson;
            var xkcdResponse = PrepareXkcdResponse(number);

            mockResponseHandler.AddMockResponse(xkcdResponse, uri);
        }
Exemplo n.º 2
0
        private HttpClient PrepareHttpClient(string jokeUri, string joke)
        {
            var mockMessageHandler = new MockResponseHandler();

            var chuckResponse = new ChuckResponse("success", new ChuckJoke(joke));

            mockMessageHandler.AddMockResponse(chuckResponse, jokeUri);

            return(new HttpClient(mockMessageHandler));
        }
Exemplo n.º 3
0
        private MockResponseHandler PrepareMockResponseHandlerForLatest(int number)
        {
            var mockResponseHandler = new MockResponseHandler();
            var uri          = _baseUri + _infoJson;
            var xkcdResponse = PrepareXkcdResponse(number);

            mockResponseHandler.AddMockResponse(xkcdResponse, uri);

            return(mockResponseHandler);
        }
Exemplo n.º 4
0
        private HttpClient PrepareHttpClient(List <string> breeds)
        {
            var baseUri   = "https://dog.ceo/api/";
            var breedsUri = $"{baseUri}breeds/list/all";

            var mockMessageHandler = new MockResponseHandler();

            var dogBreedResponse = new DogBreedsResponse("success", breeds.ToDictionary(k => k, k => Enumerable.Empty <string>().ToList()));

            mockMessageHandler.AddMockResponse(dogBreedResponse, breedsUri);

            return(new HttpClient(mockMessageHandler));
        }
Exemplo n.º 5
0
        private HttpClient PrepareHttpClient()
        {
            var baseUri   = "https://dog.ceo/api/";
            var breedsUri = $"{baseUri}breeds/image/random";

            var mockMessageHandler = new MockResponseHandler();

            var dogBreedResponse = new DogResponse("success", "https://images.dog.ceo/breeds/random.jpg");

            mockMessageHandler.AddMockResponse(dogBreedResponse, breedsUri);

            return(new HttpClient(mockMessageHandler));
        }
Exemplo n.º 6
0
        private HttpClient PrepareHttpClient(string breedName, string breedId, int responseCount = 1)
        {
            var baseUri        = "https://api.thecatapi.com/v1/";
            var breedFinderUri = $"{baseUri}breeds/search?q={HttpUtility.UrlEncode(breedName)}";
            var imageFinderUri = $"{baseUri}images/search?size=small&breed_id={breedId}";

            var mockMessageHandler = new MockResponseHandler();

            var catBreedResponse = Enumerable.Range(0, responseCount)
                                   .Select(c => new CatBreedsResponse(breedId, breedName))
                                   .ToList();

            mockMessageHandler.AddMockResponse(catBreedResponse, breedFinderUri);

            var catImageResponse = Enumerable.Range(0, responseCount)
                                   .Select(c => new CatResponse(new Uri("https://cdn2.thecatapi.com/images/" + breedId + ".jpg")))
                                   .ToList();

            mockMessageHandler.AddMockResponse(catImageResponse, imageFinderUri);

            return(new HttpClient(mockMessageHandler));
        }
Exemplo n.º 7
0
        private HttpClient PrepareHttpClient(List <string> breeds)
        {
            var baseUri   = "https://api.thecatapi.com/v1/";
            var breedsUri = $"{baseUri}breeds";

            var mockMessageHandler = new MockResponseHandler();

            var catBreedResponse = breeds
                                   .Select(c => new CatBreedsResponse("", c))
                                   .ToList();

            mockMessageHandler.AddMockResponse(catBreedResponse, breedsUri);

            return(new HttpClient(mockMessageHandler));
        }