public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockMovieConceptsRepository = MovieConceptsMockingSetup.DoMockingSetupForRepository();
     mockMovieConceptsRepository.Setup(m => m.Search(It.IsAny<IMovieConceptSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IMovieConcept>>().Object);
     var businessWorkflow = new MovieConceptsBusinessWorkflow(mockMovieConceptsRepository.Object, new MovieConceptMapper());
     var model = MovieConceptsMockingSetup.DoMockingSetupForMovieConceptModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockMovieConceptsRepository.Verify(m => m.Add(It.IsAny<IMovieConcept>()), Times.Once);
 }
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockMovieConceptsRepository = MovieConceptsMockingSetup.DoMockingSetupForRepository();

            mockMovieConceptsRepository.Setup(m => m.Search(It.IsAny <IMovieConceptSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IMovieConcept> >().Object);
            var businessWorkflow = new MovieConceptsBusinessWorkflow(mockMovieConceptsRepository.Object, new MovieConceptMapper());
            var model            = MovieConceptsMockingSetup.DoMockingSetupForMovieConceptModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockMovieConceptsRepository.Verify(m => m.Add(It.IsAny <IMovieConcept>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockMovieConceptsRepository = MovieConceptsMockingSetup.DoMockingSetupForRepository();
     var mockMovieConcept = MovieConceptsMockingSetup.DoMockingSetupForMovieConcept(1);
     mockMovieConceptsRepository.Setup(m => m.Search(It.IsAny<IMovieConceptSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IMovieConcept> { mockMovieConcept.Object } );
     mockMovieConceptsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockMovieConcept.Object);
     var businessWorkflow = new MovieConceptsBusinessWorkflow(mockMovieConceptsRepository.Object, new MovieConceptMapper());
     var model = MovieConceptsMockingSetup.DoMockingSetupForMovieConceptModel();
     // 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
     mockMovieConceptsRepository.Verify(m => m.Add(It.IsAny<IMovieConcept>()), Times.Never);
 }
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockMovieConceptsRepository = MovieConceptsMockingSetup.DoMockingSetupForRepository();
            var mockMovieConcept            = MovieConceptsMockingSetup.DoMockingSetupForMovieConcept(1);

            mockMovieConceptsRepository.Setup(m => m.Search(It.IsAny <IMovieConceptSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IMovieConcept> {
                mockMovieConcept.Object
            });
            mockMovieConceptsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockMovieConcept.Object);
            var businessWorkflow = new MovieConceptsBusinessWorkflow(mockMovieConceptsRepository.Object, new MovieConceptMapper());
            var model            = MovieConceptsMockingSetup.DoMockingSetupForMovieConceptModel();

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