コード例 #1
0
        public void MovieTagsService_GetByTagId_ReturnsListOfAllMovieTags()
        {
            //Arrange

            List <MovieTag> movieTagsList = new List <MovieTag>();

            movieTagsList.Add(_movieTag);
            IEnumerable <MovieTag>         movieTags    = movieTagsList;
            Task <IEnumerable <MovieTag> > responseTask = Task.FromResult(movieTags);

            int             expectedCount   = 1;
            MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object);

            _mockMovieTagsRepostitory.Setup(x => x.GetByTagId(It.IsAny <int>())).Returns(responseTask);

            //Act

            var resultAction = movieTagService.GetByTagId(_movieTag.Tagid).ConfigureAwait(false).GetAwaiter().GetResult().ToList();

            //Assert

            Assert.IsNotNull(resultAction);
            Assert.AreEqual(resultAction.Count, expectedCount);
            Assert.IsInstanceOfType(resultAction[0], typeof(MovieTagsDomainModel));
            Assert.AreEqual(resultAction[0].MovieId, _movieTag.MovieId);
            Assert.AreEqual(resultAction[0].TagId, _movieTag.Tagid);
        }
コード例 #2
0
        public void MovieTagsService_GetByTagId_RepositoryReturnsNull_ReturnsNull()
        {
            //Arrange

            IEnumerable <MovieTag>         movieTags    = null;
            Task <IEnumerable <MovieTag> > responseTask = Task.FromResult(movieTags);

            MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object);

            _mockMovieTagsRepostitory.Setup(x => x.GetByTagId(It.IsAny <int>())).Returns(responseTask);

            //Act

            var resultAction = movieTagService.GetByTagId(_movieTag.Tagid).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert

            Assert.IsNull(resultAction);
        }