public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockMoviesRepository = MoviesMockingSetup.DoMockingSetupForRepository();
     mockMoviesRepository.Setup(m => m.Search(It.IsAny<IMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IMovie>>().Object);
     var businessWorkflow = new MoviesBusinessWorkflow(mockMoviesRepository.Object, new MovieMapper());
     var model = MoviesMockingSetup.DoMockingSetupForMovieModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockMoviesRepository.Verify(m => m.Add(It.IsAny<IMovie>()), Times.Once);
 }
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockMoviesRepository = MoviesMockingSetup.DoMockingSetupForRepository();

            mockMoviesRepository.Setup(m => m.Search(It.IsAny <IMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IMovie> >().Object);
            var businessWorkflow = new MoviesBusinessWorkflow(mockMoviesRepository.Object, new MovieMapper());
            var model            = MoviesMockingSetup.DoMockingSetupForMovieModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockMoviesRepository.Verify(m => m.Add(It.IsAny <IMovie>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockMoviesRepository = MoviesMockingSetup.DoMockingSetupForRepository();
     var mockMovie = MoviesMockingSetup.DoMockingSetupForMovie(1);
     mockMoviesRepository.Setup(m => m.Search(It.IsAny<IMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IMovie> { mockMovie.Object } );
     mockMoviesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockMovie.Object);
     var businessWorkflow = new MoviesBusinessWorkflow(mockMoviesRepository.Object, new MovieMapper());
     var model = MoviesMockingSetup.DoMockingSetupForMovieModel();
     // 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
     mockMoviesRepository.Verify(m => m.Add(It.IsAny<IMovie>()), Times.Never);
 }
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockMoviesRepository = MoviesMockingSetup.DoMockingSetupForRepository();
            var mockMovie            = MoviesMockingSetup.DoMockingSetupForMovie(1);

            mockMoviesRepository.Setup(m => m.Search(It.IsAny <IMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IMovie> {
                mockMovie.Object
            });
            mockMoviesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockMovie.Object);
            var businessWorkflow = new MoviesBusinessWorkflow(mockMoviesRepository.Object, new MovieMapper());
            var model            = MoviesMockingSetup.DoMockingSetupForMovieModel();

            // 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
            mockMoviesRepository.Verify(m => m.Add(It.IsAny <IMovie>()), Times.Never);
        }