public void Verify_Create_Should_AddANewEntityObjectToTheDatabase() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); mockEpisodeStoryArcsRepository.Setup(m => m.Search(It.IsAny<IEpisodeStoryArcSearchModel>(), It.IsAny<bool>())) .Returns(() => new Mock<List<IEpisodeStoryArc>>().Object); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, new EpisodeStoryArcMapper()); var model = EpisodeStoryArcsMockingSetup.DoMockingSetupForEpisodeStoryArcModel(); // Act try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ } // Assert mockEpisodeStoryArcsRepository.Verify(m => m.Add(It.IsAny<IEpisodeStoryArc>()), Times.Once); }
public void Verify_Create_Should_AddANewEntityObjectToTheDatabase() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); mockEpisodeStoryArcsRepository.Setup(m => m.Search(It.IsAny <IEpisodeStoryArcSearchModel>(), It.IsAny <bool>())) .Returns(() => new Mock <List <IEpisodeStoryArc> >().Object); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, new EpisodeStoryArcMapper()); var model = EpisodeStoryArcsMockingSetup.DoMockingSetupForEpisodeStoryArcModel(); // Act try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ } // Assert mockEpisodeStoryArcsRepository.Verify(m => m.Add(It.IsAny <IEpisodeStoryArc>()), Times.Once); }
public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); var mockEpisodeStoryArc = EpisodeStoryArcsMockingSetup.DoMockingSetupForEpisodeStoryArc(1); mockEpisodeStoryArcsRepository.Setup(m => m.Search(It.IsAny<IEpisodeStoryArcSearchModel>(), It.IsAny<bool>())) .Returns(() => new List<IEpisodeStoryArc> { mockEpisodeStoryArc.Object } ); mockEpisodeStoryArcsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockEpisodeStoryArc.Object); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, new EpisodeStoryArcMapper()); var model = EpisodeStoryArcsMockingSetup.DoMockingSetupForEpisodeStoryArcModel(); // 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 mockEpisodeStoryArcsRepository.Verify(m => m.Add(It.IsAny<IEpisodeStoryArc>()), Times.Never); }
public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal() { // Arrange var mockEpisodeStoryArcsRepository = EpisodeStoryArcsMockingSetup.DoMockingSetupForRepository(); var mockEpisodeStoryArc = EpisodeStoryArcsMockingSetup.DoMockingSetupForEpisodeStoryArc(1); mockEpisodeStoryArcsRepository.Setup(m => m.Search(It.IsAny <IEpisodeStoryArcSearchModel>(), It.IsAny <bool>())) .Returns(() => new List <IEpisodeStoryArc> { mockEpisodeStoryArc.Object }); mockEpisodeStoryArcsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockEpisodeStoryArc.Object); var businessWorkflow = new EpisodeStoryArcsBusinessWorkflow(mockEpisodeStoryArcsRepository.Object, new EpisodeStoryArcMapper()); var model = EpisodeStoryArcsMockingSetup.DoMockingSetupForEpisodeStoryArcModel(); // 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 mockEpisodeStoryArcsRepository.Verify(m => m.Add(It.IsAny <IEpisodeStoryArc>()), Times.Never); }