public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
 {
     // Arrange
     var mockConceptMoviesRepository = ConceptMoviesMockingSetup.DoMockingSetupForRepository();
     mockConceptMoviesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => null);
     var mockConceptMoviesMapper = new Mock<IConceptMovieMapper>();
     mockConceptMoviesMapper.Setup(m => m.AreEqual(It.IsAny<IConceptMovieModel>(), It.IsAny<IConceptMovie>())).Returns(() => true);
     var businessWorkflow = new ConceptMoviesBusinessWorkflow(mockConceptMoviesRepository.Object, mockConceptMoviesMapper.Object);
     // Act/Assert
     Assert.Throws<System.InvalidOperationException>(() => businessWorkflow.Deactivate(1));
 }
Beispiel #2
0
        public void Verify_Deactivate_ByKey_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
        {
            // Arrange
            var mockConceptMoviesRepository = ConceptMoviesMockingSetup.DoMockingSetupForRepository();

            mockConceptMoviesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var mockConceptMoviesMapper = new Mock <IConceptMovieMapper>();

            mockConceptMoviesMapper.Setup(m => m.AreEqual(It.IsAny <IConceptMovieModel>(), It.IsAny <IConceptMovie>())).Returns(() => true);
            var businessWorkflow = new ConceptMoviesBusinessWorkflow(mockConceptMoviesRepository.Object, mockConceptMoviesMapper.Object);

            // Act/Assert
            Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate("TEST"));
        }
Beispiel #3
0
        public void Verify_Deactivate_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockConceptMoviesRepository = ConceptMoviesMockingSetup.DoMockingSetupForRepository();
            var mockConceptMoviesMapper     = new Mock <IConceptMovieMapper>();

            mockConceptMoviesMapper.Setup(m => m.AreEqual(It.IsAny <IConceptMovieModel>(), It.IsAny <IConceptMovie>())).Returns(() => true);
            var businessWorkflow = new ConceptMoviesBusinessWorkflow(mockConceptMoviesRepository.Object, mockConceptMoviesMapper.Object);

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

            // Assert
            mockConceptMoviesRepository.Verify(m => m.Deactivate(It.IsAny <IConceptMovie>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Deactivate_ByID_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockConceptMoviesRepository = ConceptMoviesMockingSetup.DoMockingSetupForRepository();
     var mockConceptMoviesMapper = new Mock<IConceptMovieMapper>();
     mockConceptMoviesMapper.Setup(m => m.AreEqual(It.IsAny<IConceptMovieModel>(), It.IsAny<IConceptMovie>())).Returns(() => true);
     var businessWorkflow = new ConceptMoviesBusinessWorkflow(mockConceptMoviesRepository.Object, mockConceptMoviesMapper.Object);
     mockConceptMoviesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => new Mock<IConceptMovie>().Object);
     mockConceptMoviesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Deactivate(1);
     // Assert
     mockConceptMoviesRepository.Verify(m => m.Deactivate(It.IsAny<IConceptMovie>()), Times.Once);
     Assert.Equal(true, result);
 }