public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockTeamMoviesRepository = TeamMoviesMockingSetup.DoMockingSetupForRepository();
     mockTeamMoviesRepository.Setup(m => m.Search(It.IsAny<ITeamMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<ITeamMovie>>().Object);
     var businessWorkflow = new TeamMoviesBusinessWorkflow(mockTeamMoviesRepository.Object, new TeamMovieMapper());
     var model = TeamMoviesMockingSetup.DoMockingSetupForTeamMovieModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockTeamMoviesRepository.Verify(m => m.Add(It.IsAny<ITeamMovie>()), Times.Once);
 }
Ejemplo n.º 2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockTeamMoviesRepository = TeamMoviesMockingSetup.DoMockingSetupForRepository();

            mockTeamMoviesRepository.Setup(m => m.Search(It.IsAny <ITeamMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <ITeamMovie> >().Object);
            var businessWorkflow = new TeamMoviesBusinessWorkflow(mockTeamMoviesRepository.Object, new TeamMovieMapper());
            var model            = TeamMoviesMockingSetup.DoMockingSetupForTeamMovieModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockTeamMoviesRepository.Verify(m => m.Add(It.IsAny <ITeamMovie>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockTeamMoviesRepository = TeamMoviesMockingSetup.DoMockingSetupForRepository();
     var mockTeamMovie = TeamMoviesMockingSetup.DoMockingSetupForTeamMovie(1);
     mockTeamMoviesRepository.Setup(m => m.Search(It.IsAny<ITeamMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<ITeamMovie> { mockTeamMovie.Object } );
     mockTeamMoviesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockTeamMovie.Object);
     var businessWorkflow = new TeamMoviesBusinessWorkflow(mockTeamMoviesRepository.Object, new TeamMovieMapper());
     var model = TeamMoviesMockingSetup.DoMockingSetupForTeamMovieModel();
     // 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
     mockTeamMoviesRepository.Verify(m => m.Add(It.IsAny<ITeamMovie>()), Times.Never);
 }
Ejemplo n.º 4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockTeamMoviesRepository = TeamMoviesMockingSetup.DoMockingSetupForRepository();
            var mockTeamMovie            = TeamMoviesMockingSetup.DoMockingSetupForTeamMovie(1);

            mockTeamMoviesRepository.Setup(m => m.Search(It.IsAny <ITeamMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <ITeamMovie> {
                mockTeamMovie.Object
            });
            mockTeamMoviesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockTeamMovie.Object);
            var businessWorkflow = new TeamMoviesBusinessWorkflow(mockTeamMoviesRepository.Object, new TeamMovieMapper());
            var model            = TeamMoviesMockingSetup.DoMockingSetupForTeamMovieModel();

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