public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockMovieTeamsRepository = MovieTeamsMockingSetup.DoMockingSetupForRepository(); mockMovieTeamsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new MovieTeamsBusinessWorkflow(mockMovieTeamsRepository.Object, new MovieTeamMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockMovieTeamsRepository = MovieTeamsMockingSetup.DoMockingSetupForRepository(); var mockMovieTeamsMapper = new Mock <IMovieTeamMapper>(); mockMovieTeamsMapper.Setup(m => m.AreEqual(It.IsAny <IMovieTeamModel>(), It.IsAny <IMovieTeam>())).Returns(() => true); var businessWorkflow = new MovieTeamsBusinessWorkflow(mockMovieTeamsRepository.Object, mockMovieTeamsMapper.Object); mockMovieTeamsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IMovieTeam>().Object); mockMovieTeamsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockMovieTeamsRepository.Verify(m => m.Remove(It.IsAny <IMovieTeam>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockMovieTeamsRepository = MovieTeamsMockingSetup.DoMockingSetupForRepository(); var mockMovieTeamsMapper = new Mock<IMovieTeamMapper>(); mockMovieTeamsMapper.Setup(m => m.AreEqual(It.IsAny<IMovieTeamModel>(), It.IsAny<IMovieTeam>())).Returns(() => true); var businessWorkflow = new MovieTeamsBusinessWorkflow(mockMovieTeamsRepository.Object, mockMovieTeamsMapper.Object); mockMovieTeamsRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<IMovieTeam>().Object); mockMovieTeamsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockMovieTeamsRepository.Verify(m => m.Remove(It.IsAny<IMovieTeam>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockMovieTeamsRepository = MovieTeamsMockingSetup.DoMockingSetupForRepository(); mockMovieTeamsRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new MovieTeamsBusinessWorkflow(mockMovieTeamsRepository.Object, new MovieTeamMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }