public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository();
     mockTeamsRepository.Setup(m => m.Search(It.IsAny<ITeamSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<ITeam>>().Object);
     var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, new TeamMapper());
     var model = TeamsMockingSetup.DoMockingSetupForTeamModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockTeamsRepository.Verify(m => m.Add(It.IsAny<ITeam>()), Times.Once);
 }
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository();

            mockTeamsRepository.Setup(m => m.Search(It.IsAny <ITeamSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <ITeam> >().Object);
            var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, new TeamMapper());
            var model            = TeamsMockingSetup.DoMockingSetupForTeamModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockTeamsRepository.Verify(m => m.Add(It.IsAny <ITeam>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository();
     var mockTeam = TeamsMockingSetup.DoMockingSetupForTeam(1);
     mockTeamsRepository.Setup(m => m.Search(It.IsAny<ITeamSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<ITeam> { mockTeam.Object } );
     mockTeamsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockTeam.Object);
     var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, new TeamMapper());
     var model = TeamsMockingSetup.DoMockingSetupForTeamModel();
     // 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
     mockTeamsRepository.Verify(m => m.Add(It.IsAny<ITeam>()), Times.Never);
 }
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository();
            var mockTeam            = TeamsMockingSetup.DoMockingSetupForTeam(1);

            mockTeamsRepository.Setup(m => m.Search(It.IsAny <ITeamSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <ITeam> {
                mockTeam.Object
            });
            mockTeamsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockTeam.Object);
            var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, new TeamMapper());
            var model            = TeamsMockingSetup.DoMockingSetupForTeamModel();

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