public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
 {
     // Arrange
     var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();
     mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => null);
     var mockEpisodeStoryArcFirstAppearancesMapper = new Mock<IEpisodeStoryArcFirstAppearanceMapper>();
     mockEpisodeStoryArcFirstAppearancesMapper.Setup(m => m.AreEqual(It.IsAny<IEpisodeStoryArcFirstAppearanceModel>(), It.IsAny<IEpisodeStoryArcFirstAppearance>())).Returns(() => true);
     var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, mockEpisodeStoryArcFirstAppearancesMapper.Object);
     // Act/Assert
     Assert.Throws<System.InvalidOperationException>(() => businessWorkflow.Deactivate(1));
 }
Example #2
0
        public void Verify_Deactivate_ByKey_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
        {
            // Arrange
            var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();

            mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var mockEpisodeStoryArcFirstAppearancesMapper = new Mock <IEpisodeStoryArcFirstAppearanceMapper>();

            mockEpisodeStoryArcFirstAppearancesMapper.Setup(m => m.AreEqual(It.IsAny <IEpisodeStoryArcFirstAppearanceModel>(), It.IsAny <IEpisodeStoryArcFirstAppearance>())).Returns(() => true);
            var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, mockEpisodeStoryArcFirstAppearancesMapper.Object);

            // Act/Assert
            Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate("TEST"));
        }
Example #3
0
        public void Verify_Deactivate_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();
            var mockEpisodeStoryArcFirstAppearancesMapper     = new Mock <IEpisodeStoryArcFirstAppearanceMapper>();

            mockEpisodeStoryArcFirstAppearancesMapper.Setup(m => m.AreEqual(It.IsAny <IEpisodeStoryArcFirstAppearanceModel>(), It.IsAny <IEpisodeStoryArcFirstAppearance>())).Returns(() => true);
            var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, mockEpisodeStoryArcFirstAppearancesMapper.Object);

            mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IEpisodeStoryArcFirstAppearance>().Object);
            mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
            // Act
            var result = businessWorkflow.Deactivate("KING-STEPHEN");

            // Assert
            mockEpisodeStoryArcFirstAppearancesRepository.Verify(m => m.Deactivate(It.IsAny <IEpisodeStoryArcFirstAppearance>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Deactivate_ByID_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();
     var mockEpisodeStoryArcFirstAppearancesMapper = new Mock<IEpisodeStoryArcFirstAppearanceMapper>();
     mockEpisodeStoryArcFirstAppearancesMapper.Setup(m => m.AreEqual(It.IsAny<IEpisodeStoryArcFirstAppearanceModel>(), It.IsAny<IEpisodeStoryArcFirstAppearance>())).Returns(() => true);
     var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, mockEpisodeStoryArcFirstAppearancesMapper.Object);
     mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => new Mock<IEpisodeStoryArcFirstAppearance>().Object);
     mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Deactivate(1);
     // Assert
     mockEpisodeStoryArcFirstAppearancesRepository.Verify(m => m.Deactivate(It.IsAny<IEpisodeStoryArcFirstAppearance>()), Times.Once);
     Assert.Equal(true, result);
 }