public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockEpisodeLocationsRepository = EpisodeLocationsMockingSetup.DoMockingSetupForRepository(); mockEpisodeLocationsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new EpisodeLocationsBusinessWorkflow(mockEpisodeLocationsRepository.Object, new EpisodeLocationMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockEpisodeLocationsRepository = EpisodeLocationsMockingSetup.DoMockingSetupForRepository(); var mockEpisodeLocationsMapper = new Mock <IEpisodeLocationMapper>(); mockEpisodeLocationsMapper.Setup(m => m.AreEqual(It.IsAny <IEpisodeLocationModel>(), It.IsAny <IEpisodeLocation>())).Returns(() => true); var businessWorkflow = new EpisodeLocationsBusinessWorkflow(mockEpisodeLocationsRepository.Object, mockEpisodeLocationsMapper.Object); mockEpisodeLocationsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IEpisodeLocation>().Object); mockEpisodeLocationsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockEpisodeLocationsRepository.Verify(m => m.Remove(It.IsAny <IEpisodeLocation>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockEpisodeLocationsRepository = EpisodeLocationsMockingSetup.DoMockingSetupForRepository(); var mockEpisodeLocationsMapper = new Mock<IEpisodeLocationMapper>(); mockEpisodeLocationsMapper.Setup(m => m.AreEqual(It.IsAny<IEpisodeLocationModel>(), It.IsAny<IEpisodeLocation>())).Returns(() => true); var businessWorkflow = new EpisodeLocationsBusinessWorkflow(mockEpisodeLocationsRepository.Object, mockEpisodeLocationsMapper.Object); mockEpisodeLocationsRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<IEpisodeLocation>().Object); mockEpisodeLocationsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockEpisodeLocationsRepository.Verify(m => m.Remove(It.IsAny<IEpisodeLocation>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockEpisodeLocationsRepository = EpisodeLocationsMockingSetup.DoMockingSetupForRepository(); mockEpisodeLocationsRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new EpisodeLocationsBusinessWorkflow(mockEpisodeLocationsRepository.Object, new EpisodeLocationMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }