public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockLocationMoviesRepository = LocationMoviesMockingSetup.DoMockingSetupForRepository(); mockLocationMoviesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new LocationMoviesBusinessWorkflow(mockLocationMoviesRepository.Object, new LocationMovieMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockLocationMoviesRepository = LocationMoviesMockingSetup.DoMockingSetupForRepository(); var mockLocationMoviesMapper = new Mock <ILocationMovieMapper>(); mockLocationMoviesMapper.Setup(m => m.AreEqual(It.IsAny <ILocationMovieModel>(), It.IsAny <ILocationMovie>())).Returns(() => true); var businessWorkflow = new LocationMoviesBusinessWorkflow(mockLocationMoviesRepository.Object, mockLocationMoviesMapper.Object); mockLocationMoviesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <ILocationMovie>().Object); mockLocationMoviesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockLocationMoviesRepository.Verify(m => m.Remove(It.IsAny <ILocationMovie>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockLocationMoviesRepository = LocationMoviesMockingSetup.DoMockingSetupForRepository(); var mockLocationMoviesMapper = new Mock<ILocationMovieMapper>(); mockLocationMoviesMapper.Setup(m => m.AreEqual(It.IsAny<ILocationMovieModel>(), It.IsAny<ILocationMovie>())).Returns(() => true); var businessWorkflow = new LocationMoviesBusinessWorkflow(mockLocationMoviesRepository.Object, mockLocationMoviesMapper.Object); mockLocationMoviesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<ILocationMovie>().Object); mockLocationMoviesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockLocationMoviesRepository.Verify(m => m.Remove(It.IsAny<ILocationMovie>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockLocationMoviesRepository = LocationMoviesMockingSetup.DoMockingSetupForRepository(); mockLocationMoviesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new LocationMoviesBusinessWorkflow(mockLocationMoviesRepository.Object, new LocationMovieMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }