Пример #1
0
        public void GetFullScheduleAsync_MockWebApiInternalServerError_HttpRequestExtException()
        {
            // Arrange
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect($"{BASE_API_URL}/schedule/full")
            .Respond(HttpStatusCode.InternalServerError);

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

            // Act and Assert
            AsyncTestDelegate act = async() => await tvMazeClient.GetFullScheduleAsync();

            //Assert.That(act, Throws.TypeOf<HttpRequestException>());

            var ex = Assert.ThrowsAsync <HttpRequestExtException>(act);

            Assert.That(ex.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
        }
Пример #2
0
        public async Task GetFullScheduleAsync_MockWebApi_FullSchedule()
        {
            // Arrange
            var json     = File.ReadAllText(Path.Combine(BasePath, DomainObjectFactoryTests.JSON_DATA_PATH, "schedule.json"));
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect($"{BASE_API_URL}/schedule/full")
            .Respond("application/json", json);

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

            // Act
            var schedule = await tvMazeClient.GetFullScheduleAsync();

            // Assert
            Assert.IsNotNull(schedule);
            Assert.IsNotEmpty(schedule.Episodes);
            mockHttp.VerifyNoOutstandingExpectation();
        }