Example #1
0
        public async Task ShowSearchAsync_MockWebApi_SearchQuery_ShowSearchResults()
        {
            // Arrange
            const string query    = "girls";
            var          json     = File.ReadAllText(Path.Combine(BasePath, DomainObjectFactoryTests.JSON_DATA_PATH, "search_show.json"));
            var          mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect($"{BASE_API_URL}/search/shows")
            .WithQueryString("q", query)
            .Respond("application/json", json);

            var tvMazeClient = new TvMazeClient(BASE_API_URL, mockHttp.ToHttpClient());

            // Act
            var results = await tvMazeClient.ShowSearchAsync(query);

            // Assert
            Assert.IsNotNull(results);
            Assert.IsNotEmpty(results);
            Assert.IsInstanceOf <Show>(results.ToArray()[0].Element);
            Assert.AreEqual(139, results.ToArray()[0].Element.Id);
            mockHttp.VerifyNoOutstandingExpectation();
        }