public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); mockEpisodeStoryArcsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => null); var mockEpisodeStoryArcsMapper = new Mock<IEpisodeStoryArcMapper>(); mockEpisodeStoryArcsMapper.Setup(m => m.AreEqual(It.IsAny<IEpisodeStoryArcModel>(), It.IsAny<IEpisodeStoryArc>())).Returns(() => true); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, mockEpisodeStoryArcsMapper.Object); // Act/Assert Assert.Throws<System.InvalidOperationException>(() => businessWorkflow.Deactivate(1)); }
public void Verify_Deactivate_ByKey_ANonExistingEntity_Should_ThrowAnInvalidOperationException() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); mockEpisodeStoryArcsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var mockEpisodeStoryArcsMapper = new Mock <IEpisodeStoryArcMapper>(); mockEpisodeStoryArcsMapper.Setup(m => m.AreEqual(It.IsAny <IEpisodeStoryArcModel>(), It.IsAny <IEpisodeStoryArc>())).Returns(() => true); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, mockEpisodeStoryArcsMapper.Object); // Act/Assert Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate("TEST")); }
public void Verify_Deactivate_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); var mockEpisodeStoryArcsMapper = new Mock <IEpisodeStoryArcMapper>(); mockEpisodeStoryArcsMapper.Setup(m => m.AreEqual(It.IsAny <IEpisodeStoryArcModel>(), It.IsAny <IEpisodeStoryArc>())).Returns(() => true); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, mockEpisodeStoryArcsMapper.Object); mockEpisodeStoryArcsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IEpisodeStoryArc>().Object); mockEpisodeStoryArcsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Deactivate("KING-STEPHEN"); // Assert mockEpisodeStoryArcsRepository.Verify(m => m.Deactivate(It.IsAny <IEpisodeStoryArc>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Deactivate_ByID_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); var mockEpisodeStoryArcsMapper = new Mock<IEpisodeStoryArcMapper>(); mockEpisodeStoryArcsMapper.Setup(m => m.AreEqual(It.IsAny<IEpisodeStoryArcModel>(), It.IsAny<IEpisodeStoryArc>())).Returns(() => true); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, mockEpisodeStoryArcsMapper.Object); mockEpisodeStoryArcsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => new Mock<IEpisodeStoryArc>().Object); mockEpisodeStoryArcsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Deactivate(1); // Assert mockEpisodeStoryArcsRepository.Verify(m => m.Deactivate(It.IsAny<IEpisodeStoryArc>()), Times.Once); Assert.Equal(true, result); }