示例#1
0
        public void MovieTagsService_DeleteByMovieId_ReturnsDeletedMovieTag()
        {
            //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.DeleteByMovieId(It.IsAny <Guid>())).Returns(responseTask);

            //Act

            var result = movieTagService.DeleteByMovieId(_movieTag.MovieId).ConfigureAwait(false).GetAwaiter().GetResult().ToList();

            //Assert

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, expectedCount);
            Assert.IsInstanceOfType(result[0], typeof(MovieTagsDomainModel));
            Assert.AreEqual(result[0].TagId, _movieTag.Tagid);
            Assert.AreEqual(result[0].MovieId, _movieTag.MovieId);
        }
示例#2
0
        public void MovieTagsService_DeleteByMovieId_RepositoryReturnsNull_ReturnsNull()
        {
            //Arrange
            IEnumerable <MovieTag>         movieTags    = null;
            Task <IEnumerable <MovieTag> > responseTask = Task.FromResult(movieTags);

            MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object);

            _mockMovieTagsRepostitory.Setup(x => x.DeleteByMovieId(It.IsAny <Guid>())).Returns(responseTask);

            //Act
            var result = movieTagService.DeleteByMovieId(_movieTag.MovieId).ConfigureAwait(false).GetAwaiter().GetResult();

            //Assert
            Assert.IsNull(result);
        }