public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockTeamAppearedInIssuesRepository = TeamAppearedInIssuesMockingSetup.DoMockingSetupForRepository();
     mockTeamAppearedInIssuesRepository.Setup(m => m.Search(It.IsAny<ITeamAppearedInIssueSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<ITeamAppearedInIssue>>().Object);
     var businessWorkflow = new TeamAppearedInIssuesBusinessWorkflow(mockTeamAppearedInIssuesRepository.Object, new TeamAppearedInIssueMapper());
     var model = TeamAppearedInIssuesMockingSetup.DoMockingSetupForTeamAppearedInIssueModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockTeamAppearedInIssuesRepository.Verify(m => m.Add(It.IsAny<ITeamAppearedInIssue>()), Times.Once);
 }
Esempio n. 2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockTeamAppearedInIssuesRepository = TeamAppearedInIssuesMockingSetup.DoMockingSetupForRepository();

            mockTeamAppearedInIssuesRepository.Setup(m => m.Search(It.IsAny <ITeamAppearedInIssueSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <ITeamAppearedInIssue> >().Object);
            var businessWorkflow = new TeamAppearedInIssuesBusinessWorkflow(mockTeamAppearedInIssuesRepository.Object, new TeamAppearedInIssueMapper());
            var model            = TeamAppearedInIssuesMockingSetup.DoMockingSetupForTeamAppearedInIssueModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockTeamAppearedInIssuesRepository.Verify(m => m.Add(It.IsAny <ITeamAppearedInIssue>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockTeamAppearedInIssuesRepository = TeamAppearedInIssuesMockingSetup.DoMockingSetupForRepository();
     var mockTeamAppearedInIssue = TeamAppearedInIssuesMockingSetup.DoMockingSetupForTeamAppearedInIssue(1);
     mockTeamAppearedInIssuesRepository.Setup(m => m.Search(It.IsAny<ITeamAppearedInIssueSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<ITeamAppearedInIssue> { mockTeamAppearedInIssue.Object } );
     mockTeamAppearedInIssuesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockTeamAppearedInIssue.Object);
     var businessWorkflow = new TeamAppearedInIssuesBusinessWorkflow(mockTeamAppearedInIssuesRepository.Object, new TeamAppearedInIssueMapper());
     var model = TeamAppearedInIssuesMockingSetup.DoMockingSetupForTeamAppearedInIssueModel();
     // 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
     mockTeamAppearedInIssuesRepository.Verify(m => m.Add(It.IsAny<ITeamAppearedInIssue>()), Times.Never);
 }
Esempio n. 4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockTeamAppearedInIssuesRepository = TeamAppearedInIssuesMockingSetup.DoMockingSetupForRepository();
            var mockTeamAppearedInIssue            = TeamAppearedInIssuesMockingSetup.DoMockingSetupForTeamAppearedInIssue(1);

            mockTeamAppearedInIssuesRepository.Setup(m => m.Search(It.IsAny <ITeamAppearedInIssueSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <ITeamAppearedInIssue> {
                mockTeamAppearedInIssue.Object
            });
            mockTeamAppearedInIssuesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockTeamAppearedInIssue.Object);
            var businessWorkflow = new TeamAppearedInIssuesBusinessWorkflow(mockTeamAppearedInIssuesRepository.Object, new TeamAppearedInIssueMapper());
            var model            = TeamAppearedInIssuesMockingSetup.DoMockingSetupForTeamAppearedInIssueModel();

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