public void GetSchedule_MockWebApi_DefaultQueryParams_Schedule() { // Arrange var json = File.ReadAllText(Path.Combine(BasePath, DomainObjectFactoryTests.JSON_DATA_PATH, "schedule.json")); var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect($"{BASE_API_URL}/schedule") .With(x => string.IsNullOrEmpty(x.RequestUri.Query)) .Respond("application/json", json); var tvMazeClient = new TvMazeClient(BASE_API_URL, mockHttp.ToHttpClient()); // Act var schedule = tvMazeClient.GetSchedule(); // Assert Assert.IsNotNull(schedule); Assert.IsNotEmpty(schedule.Episodes); mockHttp.VerifyNoOutstandingExpectation(); }
public void GetSchedule_MockWebApi_WithQueryParams_Schedule() { // Arrange var json = File.ReadAllText(Path.Combine(BasePath, DomainObjectFactoryTests.JSON_DATA_PATH, "schedule.json")); var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect($"{BASE_API_URL}/schedule?country=US&date=2014-12-01") .WithQueryString("country", "US") .WithQueryString("date", "2014-12-01") .Respond("application/json", json); var tvMazeClient = new TvMazeClient(BASE_API_URL, mockHttp.ToHttpClient()); // Act var schedule = tvMazeClient.GetSchedule("US", new DateTime(2014, 12, 01)); // Assert Assert.IsNotNull(schedule); Assert.IsNotEmpty(schedule.Episodes); mockHttp.VerifyNoOutstandingExpectation(); }