public void MovieTagsService_GetAllAsync_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.GetAll()).Returns(responseTask); //Act var resultAction = movieTagService.GetAllAsync().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); }
public void MovieTagsService_GetAllAsync_RepositoryReturnsNull_ReturnsNull() { //Arrange IEnumerable <MovieTag> movieTags = null; Task <IEnumerable <MovieTag> > responseTask = Task.FromResult(movieTags); MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object); _mockMovieTagsRepostitory.Setup(x => x.GetAll()).Returns(responseTask); //Act var resultAction = movieTagService.GetAllAsync().ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(resultAction); }