public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockMovieObjectsRepository = MovieObjectsMockingSetup.DoMockingSetupForRepository();
     mockMovieObjectsRepository.Setup(m => m.Search(It.IsAny<IMovieObjectSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IMovieObject>>().Object);
     var businessWorkflow = new MovieObjectsBusinessWorkflow(mockMovieObjectsRepository.Object, new MovieObjectMapper());
     var model = MovieObjectsMockingSetup.DoMockingSetupForMovieObjectModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockMovieObjectsRepository.Verify(m => m.Add(It.IsAny<IMovieObject>()), Times.Once);
 }
示例#2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockMovieObjectsRepository = MovieObjectsMockingSetup.DoMockingSetupForRepository();

            mockMovieObjectsRepository.Setup(m => m.Search(It.IsAny <IMovieObjectSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IMovieObject> >().Object);
            var businessWorkflow = new MovieObjectsBusinessWorkflow(mockMovieObjectsRepository.Object, new MovieObjectMapper());
            var model            = MovieObjectsMockingSetup.DoMockingSetupForMovieObjectModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockMovieObjectsRepository.Verify(m => m.Add(It.IsAny <IMovieObject>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockMovieObjectsRepository = MovieObjectsMockingSetup.DoMockingSetupForRepository();
     var mockMovieObject = MovieObjectsMockingSetup.DoMockingSetupForMovieObject(1);
     mockMovieObjectsRepository.Setup(m => m.Search(It.IsAny<IMovieObjectSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IMovieObject> { mockMovieObject.Object } );
     mockMovieObjectsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockMovieObject.Object);
     var businessWorkflow = new MovieObjectsBusinessWorkflow(mockMovieObjectsRepository.Object, new MovieObjectMapper());
     var model = MovieObjectsMockingSetup.DoMockingSetupForMovieObjectModel();
     // 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
     mockMovieObjectsRepository.Verify(m => m.Add(It.IsAny<IMovieObject>()), Times.Never);
 }
示例#4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockMovieObjectsRepository = MovieObjectsMockingSetup.DoMockingSetupForRepository();
            var mockMovieObject            = MovieObjectsMockingSetup.DoMockingSetupForMovieObject(1);

            mockMovieObjectsRepository.Setup(m => m.Search(It.IsAny <IMovieObjectSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IMovieObject> {
                mockMovieObject.Object
            });
            mockMovieObjectsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockMovieObject.Object);
            var businessWorkflow = new MovieObjectsBusinessWorkflow(mockMovieObjectsRepository.Object, new MovieObjectMapper());
            var model            = MovieObjectsMockingSetup.DoMockingSetupForMovieObjectModel();

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