public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockObjectMoviesRepository = ObjectMoviesMockingSetup.DoMockingSetupForRepository();
     mockObjectMoviesRepository.Setup(m => m.Search(It.IsAny<IObjectMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IObjectMovie>>().Object);
     var businessWorkflow = new ObjectMoviesBusinessWorkflow(mockObjectMoviesRepository.Object, new ObjectMovieMapper());
     var model = ObjectMoviesMockingSetup.DoMockingSetupForObjectMovieModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockObjectMoviesRepository.Verify(m => m.Add(It.IsAny<IObjectMovie>()), Times.Once);
 }
Ejemplo n.º 2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockObjectMoviesRepository = ObjectMoviesMockingSetup.DoMockingSetupForRepository();

            mockObjectMoviesRepository.Setup(m => m.Search(It.IsAny <IObjectMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IObjectMovie> >().Object);
            var businessWorkflow = new ObjectMoviesBusinessWorkflow(mockObjectMoviesRepository.Object, new ObjectMovieMapper());
            var model            = ObjectMoviesMockingSetup.DoMockingSetupForObjectMovieModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockObjectMoviesRepository.Verify(m => m.Add(It.IsAny <IObjectMovie>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockObjectMoviesRepository = ObjectMoviesMockingSetup.DoMockingSetupForRepository();
     var mockObjectMovie = ObjectMoviesMockingSetup.DoMockingSetupForObjectMovie(1);
     mockObjectMoviesRepository.Setup(m => m.Search(It.IsAny<IObjectMovieSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IObjectMovie> { mockObjectMovie.Object } );
     mockObjectMoviesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockObjectMovie.Object);
     var businessWorkflow = new ObjectMoviesBusinessWorkflow(mockObjectMoviesRepository.Object, new ObjectMovieMapper());
     var model = ObjectMoviesMockingSetup.DoMockingSetupForObjectMovieModel();
     // 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
     mockObjectMoviesRepository.Verify(m => m.Add(It.IsAny<IObjectMovie>()), Times.Never);
 }
Ejemplo n.º 4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockObjectMoviesRepository = ObjectMoviesMockingSetup.DoMockingSetupForRepository();
            var mockObjectMovie            = ObjectMoviesMockingSetup.DoMockingSetupForObjectMovie(1);

            mockObjectMoviesRepository.Setup(m => m.Search(It.IsAny <IObjectMovieSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IObjectMovie> {
                mockObjectMovie.Object
            });
            mockObjectMoviesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockObjectMovie.Object);
            var businessWorkflow = new ObjectMoviesBusinessWorkflow(mockObjectMoviesRepository.Object, new ObjectMovieMapper());
            var model            = ObjectMoviesMockingSetup.DoMockingSetupForObjectMovieModel();

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