Beispiel #1
0
        public async Task PeopleSearchAsync_MockWebApi_SearchQuery_PeopleSearchResults()
        {
            // Arrange
            const string query    = "lauren";
            var          json     = File.ReadAllText(Path.Combine(BasePath, DomainObjectFactoryTests.JSON_DATA_PATH, "search_people.json"));
            var          mockHttp = new MockHttpMessageHandler();

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

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

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

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