Beispiel #1
0
        public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
        {
            // Arrange
            var mockConceptMoviesRepository = ConceptMoviesMockingSetup.DoMockingSetupForRepository();

            mockConceptMoviesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var businessWorkflow = new ConceptMoviesBusinessWorkflow(mockConceptMoviesRepository.Object, new ConceptMovieMapper());
            // Act
            var result = businessWorkflow.Remove("DOESNT-EXIST");

            // Assert
            Assert.Equal(true, result);
        }
Beispiel #2
0
        public void Verify_Remove_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.Remove("KING-STEPHEN");

            // Assert
            mockConceptMoviesRepository.Verify(m => m.Remove(It.IsAny <IConceptMovie>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Remove_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.Remove("KING-STEPHEN");
     // Assert
     mockConceptMoviesRepository.Verify(m => m.Remove(It.IsAny<IConceptMovie>()), Times.Once);
     Assert.Equal(true, result);
 }
 public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue()
 {
     // Arrange
     var mockConceptMoviesRepository = ConceptMoviesMockingSetup.DoMockingSetupForRepository();
     mockConceptMoviesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null);
     var businessWorkflow = new ConceptMoviesBusinessWorkflow(mockConceptMoviesRepository.Object, new ConceptMovieMapper());
     // Act
     var result = businessWorkflow.Remove("DOESNT-EXIST");
     // Assert
     Assert.Equal(true, result);
 }