コード例 #1
0
        public void GetSimilarTelevisionShowsById_When_TheMovieDbDispatcherThrowsException_Throws_Exception()
        {
            _entertainmentDispatcherMock.Setup(x => x.GetSimilarTelevisionShowsById(It.IsAny <int>())).Throws <Exception>();
            var televisionService = new CodeSample.Services.TelevisionService(_entertainmentDispatcherMock.Object);

            Assert.Catch <Exception>(() => televisionService.GetSimilarTelevisionShowsById(0));
        }
        public void GetTelevisionShowsByQuery_When_TheMovieDbDispatcherThrowsException_Throws_Exception()
        {
            _entertainmentDispatcherMock.Setup(x => x.GetTelevisionShowsByQuery(It.IsAny <string>())).Throws <Exception>();
            var televisionService = new CodeSample.Services.TelevisionService(_entertainmentDispatcherMock.Object);

            Assert.Catch <Exception>(() => televisionService.GetTelevisionShowsByQuery(null));
        }
コード例 #3
0
        public void GetSimilarTelevisionShowsById_When_Successful_Returns_TelevisionSearchResponseDTO()
        {
            var expectedResult = Builder <TelevisionSearchResponseDto> .CreateNew().Build();

            _entertainmentDispatcherMock.Setup(x => x.GetSimilarTelevisionShowsById(It.IsAny <int>())).Returns(expectedResult);
            var televisionService = new CodeSample.Services.TelevisionService(_entertainmentDispatcherMock.Object);
            var actualResult      = televisionService.GetSimilarTelevisionShowsById(0);

            actualResult.ToExpectedObject().ShouldEqual(expectedResult);
        }
コード例 #4
0
        public void GetSimilarTelevisionShowsById_When_TheMovieDbDispatcherThrowsStrategyCorpsException_Throws_Exception()
        {
            var expectedException = Builder <StrategyCorpsException> .CreateNew()
                                    .With(x => x.StrategyCorpsErrorCode = ErrorCode.Default).Build();

            _entertainmentDispatcherMock.Setup(x => x.GetSimilarTelevisionShowsById(It.IsAny <int>())).Throws(expectedException);
            var televisionService = new CodeSample.Services.TelevisionService(_entertainmentDispatcherMock.Object);

            var actualException = Assert.Catch <Exception>(() => televisionService.GetSimilarTelevisionShowsById(0));

            actualException.ToExpectedObject().ShouldEqual(expectedException);
        }