public void Verify_Create_Should_AddANewEntityObjectToTheDatabase() { // Arrange var mockVolumeTeamsRepository = VolumeTeamsMockingSetup.DoMockingSetupForRepository(); mockVolumeTeamsRepository.Setup(m => m.Search(It.IsAny<IVolumeTeamSearchModel>(), It.IsAny<bool>())) .Returns(() => new Mock<List<IVolumeTeam>>().Object); var businessWorkflow = new VolumeTeamsBusinessWorkflow(mockVolumeTeamsRepository.Object, new VolumeTeamMapper()); var model = VolumeTeamsMockingSetup.DoMockingSetupForVolumeTeamModel(); // Act try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ } // Assert mockVolumeTeamsRepository.Verify(m => m.Add(It.IsAny<IVolumeTeam>()), Times.Once); }
public void Verify_Create_Should_AddANewEntityObjectToTheDatabase() { // Arrange var mockVolumeTeamsRepository = VolumeTeamsMockingSetup.DoMockingSetupForRepository(); mockVolumeTeamsRepository.Setup(m => m.Search(It.IsAny <IVolumeTeamSearchModel>(), It.IsAny <bool>())) .Returns(() => new Mock <List <IVolumeTeam> >().Object); var businessWorkflow = new VolumeTeamsBusinessWorkflow(mockVolumeTeamsRepository.Object, new VolumeTeamMapper()); var model = VolumeTeamsMockingSetup.DoMockingSetupForVolumeTeamModel(); // Act try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ } // Assert mockVolumeTeamsRepository.Verify(m => m.Add(It.IsAny <IVolumeTeam>()), Times.Once); }
public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal() { // Arrange var mockVolumeTeamsRepository = VolumeTeamsMockingSetup.DoMockingSetupForRepository(); var mockVolumeTeam = VolumeTeamsMockingSetup.DoMockingSetupForVolumeTeam(1); mockVolumeTeamsRepository.Setup(m => m.Search(It.IsAny<IVolumeTeamSearchModel>(), It.IsAny<bool>())) .Returns(() => new List<IVolumeTeam> { mockVolumeTeam.Object } ); mockVolumeTeamsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockVolumeTeam.Object); var businessWorkflow = new VolumeTeamsBusinessWorkflow(mockVolumeTeamsRepository.Object, new VolumeTeamMapper()); var model = VolumeTeamsMockingSetup.DoMockingSetupForVolumeTeamModel(); // 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 mockVolumeTeamsRepository.Verify(m => m.Add(It.IsAny<IVolumeTeam>()), Times.Never); }
public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal() { // Arrange var mockVolumeTeamsRepository = VolumeTeamsMockingSetup.DoMockingSetupForRepository(); var mockVolumeTeam = VolumeTeamsMockingSetup.DoMockingSetupForVolumeTeam(1); mockVolumeTeamsRepository.Setup(m => m.Search(It.IsAny <IVolumeTeamSearchModel>(), It.IsAny <bool>())) .Returns(() => new List <IVolumeTeam> { mockVolumeTeam.Object }); mockVolumeTeamsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockVolumeTeam.Object); var businessWorkflow = new VolumeTeamsBusinessWorkflow(mockVolumeTeamsRepository.Object, new VolumeTeamMapper()); var model = VolumeTeamsMockingSetup.DoMockingSetupForVolumeTeamModel(); // 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 mockVolumeTeamsRepository.Verify(m => m.Add(It.IsAny <IVolumeTeam>()), Times.Never); }