public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockVolumeConceptsRepository = VolumeConceptsMockingSetup.DoMockingSetupForRepository();
     mockVolumeConceptsRepository.Setup(m => m.Search(It.IsAny<IVolumeConceptSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IVolumeConcept>>().Object);
     var businessWorkflow = new VolumeConceptsBusinessWorkflow(mockVolumeConceptsRepository.Object, new VolumeConceptMapper());
     var model = VolumeConceptsMockingSetup.DoMockingSetupForVolumeConceptModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockVolumeConceptsRepository.Verify(m => m.Add(It.IsAny<IVolumeConcept>()), Times.Once);
 }
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockVolumeConceptsRepository = VolumeConceptsMockingSetup.DoMockingSetupForRepository();

            mockVolumeConceptsRepository.Setup(m => m.Search(It.IsAny <IVolumeConceptSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IVolumeConcept> >().Object);
            var businessWorkflow = new VolumeConceptsBusinessWorkflow(mockVolumeConceptsRepository.Object, new VolumeConceptMapper());
            var model            = VolumeConceptsMockingSetup.DoMockingSetupForVolumeConceptModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockVolumeConceptsRepository.Verify(m => m.Add(It.IsAny <IVolumeConcept>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockVolumeConceptsRepository = VolumeConceptsMockingSetup.DoMockingSetupForRepository();
     var mockVolumeConcept = VolumeConceptsMockingSetup.DoMockingSetupForVolumeConcept(1);
     mockVolumeConceptsRepository.Setup(m => m.Search(It.IsAny<IVolumeConceptSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IVolumeConcept> { mockVolumeConcept.Object } );
     mockVolumeConceptsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockVolumeConcept.Object);
     var businessWorkflow = new VolumeConceptsBusinessWorkflow(mockVolumeConceptsRepository.Object, new VolumeConceptMapper());
     var model = VolumeConceptsMockingSetup.DoMockingSetupForVolumeConceptModel();
     // 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
     mockVolumeConceptsRepository.Verify(m => m.Add(It.IsAny<IVolumeConcept>()), Times.Never);
 }
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockVolumeConceptsRepository = VolumeConceptsMockingSetup.DoMockingSetupForRepository();
            var mockVolumeConcept            = VolumeConceptsMockingSetup.DoMockingSetupForVolumeConcept(1);

            mockVolumeConceptsRepository.Setup(m => m.Search(It.IsAny <IVolumeConceptSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IVolumeConcept> {
                mockVolumeConcept.Object
            });
            mockVolumeConceptsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockVolumeConcept.Object);
            var businessWorkflow = new VolumeConceptsBusinessWorkflow(mockVolumeConceptsRepository.Object, new VolumeConceptMapper());
            var model            = VolumeConceptsMockingSetup.DoMockingSetupForVolumeConceptModel();

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