public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();
     mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Search(It.IsAny<IEpisodeStoryArcFirstAppearanceSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IEpisodeStoryArcFirstAppearance>>().Object);
     var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, new EpisodeStoryArcFirstAppearanceMapper());
     var model = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForEpisodeStoryArcFirstAppearanceModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockEpisodeStoryArcFirstAppearancesRepository.Verify(m => m.Add(It.IsAny<IEpisodeStoryArcFirstAppearance>()), Times.Once);
 }
Exemple #2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();

            mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Search(It.IsAny <IEpisodeStoryArcFirstAppearanceSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IEpisodeStoryArcFirstAppearance> >().Object);
            var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, new EpisodeStoryArcFirstAppearanceMapper());
            var model            = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForEpisodeStoryArcFirstAppearanceModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockEpisodeStoryArcFirstAppearancesRepository.Verify(m => m.Add(It.IsAny <IEpisodeStoryArcFirstAppearance>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();
     var mockEpisodeStoryArcFirstAppearance = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForEpisodeStoryArcFirstAppearance(1);
     mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Search(It.IsAny<IEpisodeStoryArcFirstAppearanceSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IEpisodeStoryArcFirstAppearance> { mockEpisodeStoryArcFirstAppearance.Object } );
     mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockEpisodeStoryArcFirstAppearance.Object);
     var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, new EpisodeStoryArcFirstAppearanceMapper());
     var model = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForEpisodeStoryArcFirstAppearanceModel();
     // 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
     mockEpisodeStoryArcFirstAppearancesRepository.Verify(m => m.Add(It.IsAny<IEpisodeStoryArcFirstAppearance>()), Times.Never);
 }
Exemple #4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockEpisodeStoryArcFirstAppearancesRepository = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForRepository();
            var mockEpisodeStoryArcFirstAppearance            = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForEpisodeStoryArcFirstAppearance(1);

            mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Search(It.IsAny <IEpisodeStoryArcFirstAppearanceSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IEpisodeStoryArcFirstAppearance> {
                mockEpisodeStoryArcFirstAppearance.Object
            });
            mockEpisodeStoryArcFirstAppearancesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockEpisodeStoryArcFirstAppearance.Object);
            var businessWorkflow = new EpisodeStoryArcFirstAppearancesBusinessWorkflow(mockEpisodeStoryArcFirstAppearancesRepository.Object, new EpisodeStoryArcFirstAppearanceMapper());
            var model            = EpisodeStoryArcFirstAppearancesMockingSetup.DoMockingSetupForEpisodeStoryArcFirstAppearanceModel();

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