public void MovieTagsService_AddMovieTag_ThrowsDbUpdateException() { //Arrange MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object); _mockMovieTagsRepostitory.Setup(x => x.Insert(It.IsAny <MovieTag>())).Throws(new DbUpdateException()); //Act var result = movieTagService.AddMovieTag(_movieTagDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); }
public void MovieTagsService_AddMovieTag_RepositoryReturnsNull_ReturnNull() { //Arrange MovieTag movieTagNull = null; MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object); _mockMovieTagsRepostitory.Setup(x => x.Insert(It.IsAny <MovieTag>())).Returns(movieTagNull); //Act var result = movieTagService.AddMovieTag(_movieTagDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNull(result); }
public void MovieTagsService_AddMovieTag_ReturnsInsertedMovieTag() { //Arrange MovieTagService movieTagService = new MovieTagService(_mockMovieTagsRepostitory.Object); _mockMovieTagsRepostitory.Setup(x => x.Insert(It.IsAny <MovieTag>())).Returns(_movieTag); //Act var result = movieTagService.AddMovieTag(_movieTagDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(MovieTagsDomainModel)); Assert.AreEqual(_movieTagDomainModel.MovieId, result.MovieId); Assert.AreEqual(_movieTagDomainModel.TagId, result.TagId); }