public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockEpisodeLocationFirstAppearancesRepository = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForRepository();
     mockEpisodeLocationFirstAppearancesRepository.Setup(m => m.Search(It.IsAny<IEpisodeLocationFirstAppearanceSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IEpisodeLocationFirstAppearance>>().Object);
     var businessWorkflow = new EpisodeLocationFirstAppearancesBusinessWorkflow(mockEpisodeLocationFirstAppearancesRepository.Object, new EpisodeLocationFirstAppearanceMapper());
     var model = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForEpisodeLocationFirstAppearanceModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockEpisodeLocationFirstAppearancesRepository.Verify(m => m.Add(It.IsAny<IEpisodeLocationFirstAppearance>()), Times.Once);
 }
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockEpisodeLocationFirstAppearancesRepository = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForRepository();

            mockEpisodeLocationFirstAppearancesRepository.Setup(m => m.Search(It.IsAny <IEpisodeLocationFirstAppearanceSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IEpisodeLocationFirstAppearance> >().Object);
            var businessWorkflow = new EpisodeLocationFirstAppearancesBusinessWorkflow(mockEpisodeLocationFirstAppearancesRepository.Object, new EpisodeLocationFirstAppearanceMapper());
            var model            = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForEpisodeLocationFirstAppearanceModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockEpisodeLocationFirstAppearancesRepository.Verify(m => m.Add(It.IsAny <IEpisodeLocationFirstAppearance>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockEpisodeLocationFirstAppearancesRepository = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForRepository();
     var mockEpisodeLocationFirstAppearance = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForEpisodeLocationFirstAppearance(1);
     mockEpisodeLocationFirstAppearancesRepository.Setup(m => m.Search(It.IsAny<IEpisodeLocationFirstAppearanceSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IEpisodeLocationFirstAppearance> { mockEpisodeLocationFirstAppearance.Object } );
     mockEpisodeLocationFirstAppearancesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockEpisodeLocationFirstAppearance.Object);
     var businessWorkflow = new EpisodeLocationFirstAppearancesBusinessWorkflow(mockEpisodeLocationFirstAppearancesRepository.Object, new EpisodeLocationFirstAppearanceMapper());
     var model = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForEpisodeLocationFirstAppearanceModel();
     // 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
     mockEpisodeLocationFirstAppearancesRepository.Verify(m => m.Add(It.IsAny<IEpisodeLocationFirstAppearance>()), Times.Never);
 }
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockEpisodeLocationFirstAppearancesRepository = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForRepository();
            var mockEpisodeLocationFirstAppearance            = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForEpisodeLocationFirstAppearance(1);

            mockEpisodeLocationFirstAppearancesRepository.Setup(m => m.Search(It.IsAny <IEpisodeLocationFirstAppearanceSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IEpisodeLocationFirstAppearance> {
                mockEpisodeLocationFirstAppearance.Object
            });
            mockEpisodeLocationFirstAppearancesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockEpisodeLocationFirstAppearance.Object);
            var businessWorkflow = new EpisodeLocationFirstAppearancesBusinessWorkflow(mockEpisodeLocationFirstAppearancesRepository.Object, new EpisodeLocationFirstAppearanceMapper());
            var model            = EpisodeLocationFirstAppearancesMockingSetup.DoMockingSetupForEpisodeLocationFirstAppearanceModel();

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