public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();
     mockTeamAliasesRepository.Setup(m => m.Search(It.IsAny<ITeamAliasSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<ITeamAlias>>().Object);
     var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, new TeamAliasMapper());
     var model = TeamAliasesMockingSetup.DoMockingSetupForTeamAliasModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockTeamAliasesRepository.Verify(m => m.Add(It.IsAny<ITeamAlias>()), Times.Once);
 }
Beispiel #2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();

            mockTeamAliasesRepository.Setup(m => m.Search(It.IsAny <ITeamAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <ITeamAlias> >().Object);
            var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, new TeamAliasMapper());
            var model            = TeamAliasesMockingSetup.DoMockingSetupForTeamAliasModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockTeamAliasesRepository.Verify(m => m.Add(It.IsAny <ITeamAlias>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();
     var mockTeamAlias = TeamAliasesMockingSetup.DoMockingSetupForTeamAlias(1);
     mockTeamAliasesRepository.Setup(m => m.Search(It.IsAny<ITeamAliasSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<ITeamAlias> { mockTeamAlias.Object } );
     mockTeamAliasesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockTeamAlias.Object);
     var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, new TeamAliasMapper());
     var model = TeamAliasesMockingSetup.DoMockingSetupForTeamAliasModel();
     // 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
     mockTeamAliasesRepository.Verify(m => m.Add(It.IsAny<ITeamAlias>()), Times.Never);
 }
Beispiel #4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();
            var mockTeamAlias             = TeamAliasesMockingSetup.DoMockingSetupForTeamAlias(1);

            mockTeamAliasesRepository.Setup(m => m.Search(It.IsAny <ITeamAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <ITeamAlias> {
                mockTeamAlias.Object
            });
            mockTeamAliasesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockTeamAlias.Object);
            var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, new TeamAliasMapper());
            var model            = TeamAliasesMockingSetup.DoMockingSetupForTeamAliasModel();

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