public void MovieTagsService_DeleteByTagId_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.DeleteByTagId(It.IsAny <int>())).Returns(responseTask); //Act var result = movieTagService.DeleteByTagId(_movieTag.Tagid).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); }
public void MovieTagsService_DeleteByTagId_RepositoryReturnsNull_ReturnsNull() { //Arrange IEnumerable <MovieTag> movieTags = null; Task <IEnumerable <MovieTag> > responseTask = Task.FromResult(movieTags); MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object); _mockMovieTagsRepostitory.Setup(x => x.DeleteByTagId(It.IsAny <int>())).Returns(responseTask); //Act var result = movieTagService.DeleteByTagId(_movieTag.Tagid).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(result); }