public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockCharacterMoviesRepository = CharacterMoviesMockingSetup.DoMockingSetupForRepository();
     mockCharacterMoviesRepository.Setup(m => m.Search(It.IsAny<ICharacterMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<ICharacterMovie>>().Object);
     var businessWorkflow = new CharacterMoviesBusinessWorkflow(mockCharacterMoviesRepository.Object, new CharacterMovieMapper());
     var model = CharacterMoviesMockingSetup.DoMockingSetupForCharacterMovieModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockCharacterMoviesRepository.Verify(m => m.Add(It.IsAny<ICharacterMovie>()), Times.Once);
 }
Beispiel #2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockCharacterMoviesRepository = CharacterMoviesMockingSetup.DoMockingSetupForRepository();

            mockCharacterMoviesRepository.Setup(m => m.Search(It.IsAny <ICharacterMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <ICharacterMovie> >().Object);
            var businessWorkflow = new CharacterMoviesBusinessWorkflow(mockCharacterMoviesRepository.Object, new CharacterMovieMapper());
            var model            = CharacterMoviesMockingSetup.DoMockingSetupForCharacterMovieModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockCharacterMoviesRepository.Verify(m => m.Add(It.IsAny <ICharacterMovie>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockCharacterMoviesRepository = CharacterMoviesMockingSetup.DoMockingSetupForRepository();
     var mockCharacterMovie = CharacterMoviesMockingSetup.DoMockingSetupForCharacterMovie(1);
     mockCharacterMoviesRepository.Setup(m => m.Search(It.IsAny<ICharacterMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<ICharacterMovie> { mockCharacterMovie.Object } );
     mockCharacterMoviesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockCharacterMovie.Object);
     var businessWorkflow = new CharacterMoviesBusinessWorkflow(mockCharacterMoviesRepository.Object, new CharacterMovieMapper());
     var model = CharacterMoviesMockingSetup.DoMockingSetupForCharacterMovieModel();
     // Act
     try { businessWorkflow.Create(model.Object); }
     catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ }
     // Assert
     mockCharacterMoviesRepository.Verify(m => m.Add(It.IsAny<ICharacterMovie>()), Times.Never);
 }
Beispiel #4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockCharacterMoviesRepository = CharacterMoviesMockingSetup.DoMockingSetupForRepository();
            var mockCharacterMovie            = CharacterMoviesMockingSetup.DoMockingSetupForCharacterMovie(1);

            mockCharacterMoviesRepository.Setup(m => m.Search(It.IsAny <ICharacterMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <ICharacterMovie> {
                mockCharacterMovie.Object
            });
            mockCharacterMoviesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockCharacterMovie.Object);
            var businessWorkflow = new CharacterMoviesBusinessWorkflow(mockCharacterMoviesRepository.Object, new CharacterMovieMapper());
            var model            = CharacterMoviesMockingSetup.DoMockingSetupForCharacterMovieModel();

            // Act
            try { businessWorkflow.Create(model.Object); }
            catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ }
            // Assert
            mockCharacterMoviesRepository.Verify(m => m.Add(It.IsAny <ICharacterMovie>()), Times.Never);
        }