示例#1
0
        public void GetSimilarMovieById_When_TheMovieDbDispatcherThrowsException_Throws_Exception()
        {
            _entertainmentDispatcherMock.Setup(x => x.GetSimilarMoviesById(It.IsAny <int>())).Throws <Exception>();
            var MovieService = new CodeSample.Services.MovieService(_entertainmentDispatcherMock.Object);

            Assert.Catch <Exception>(() => MovieService.GetSimilarMoviesById(0));
        }
示例#2
0
        public void GetSimilarMovieById_When_Successful_Returns_MovieSearchResponseDTO()
        {
            var expectedResult = Builder <MovieSearchResponseDto> .CreateNew().Build();

            _entertainmentDispatcherMock.Setup(x => x.GetSimilarMoviesById(It.IsAny <int>())).Returns(expectedResult);
            var movieService = new CodeSample.Services.MovieService(_entertainmentDispatcherMock.Object);
            var actualResult = movieService.GetSimilarMoviesById(0);

            actualResult.ToExpectedObject().ShouldEqual(expectedResult);
        }
示例#3
0
        public void GetSimilarMovieById_When_TheMovieDbDispatcherThrowsStrategyCorpsException_Throws_Exception()
        {
            var expectedException = Builder <StrategyCorpsException> .CreateNew()
                                    .With(x => x.StrategyCorpsErrorCode = ErrorCode.Default).Build();

            _entertainmentDispatcherMock.Setup(x => x.GetSimilarMoviesById(It.IsAny <int>())).Throws(expectedException);
            var movieService = new CodeSample.Services.MovieService(_entertainmentDispatcherMock.Object);

            var actualException = Assert.Catch <Exception>(() => movieService.GetSimilarMoviesById(0));

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