public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockPersonAliasesRepository = PersonAliasesMockingSetup.DoMockingSetupForRepository();
     mockPersonAliasesRepository.Setup(m => m.Search(It.IsAny<IPersonAliasSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IPersonAlias>>().Object);
     var businessWorkflow = new PersonAliasesBusinessWorkflow(mockPersonAliasesRepository.Object, new PersonAliasMapper());
     var model = PersonAliasesMockingSetup.DoMockingSetupForPersonAliasModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockPersonAliasesRepository.Verify(m => m.Add(It.IsAny<IPersonAlias>()), Times.Once);
 }
Esempio n. 2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockPersonAliasesRepository = PersonAliasesMockingSetup.DoMockingSetupForRepository();

            mockPersonAliasesRepository.Setup(m => m.Search(It.IsAny <IPersonAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IPersonAlias> >().Object);
            var businessWorkflow = new PersonAliasesBusinessWorkflow(mockPersonAliasesRepository.Object, new PersonAliasMapper());
            var model            = PersonAliasesMockingSetup.DoMockingSetupForPersonAliasModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockPersonAliasesRepository.Verify(m => m.Add(It.IsAny <IPersonAlias>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockPersonAliasesRepository = PersonAliasesMockingSetup.DoMockingSetupForRepository();
     var mockPersonAlias = PersonAliasesMockingSetup.DoMockingSetupForPersonAlias(1);
     mockPersonAliasesRepository.Setup(m => m.Search(It.IsAny<IPersonAliasSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IPersonAlias> { mockPersonAlias.Object } );
     mockPersonAliasesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockPersonAlias.Object);
     var businessWorkflow = new PersonAliasesBusinessWorkflow(mockPersonAliasesRepository.Object, new PersonAliasMapper());
     var model = PersonAliasesMockingSetup.DoMockingSetupForPersonAliasModel();
     // 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
     mockPersonAliasesRepository.Verify(m => m.Add(It.IsAny<IPersonAlias>()), Times.Never);
 }
Esempio n. 4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockPersonAliasesRepository = PersonAliasesMockingSetup.DoMockingSetupForRepository();
            var mockPersonAlias             = PersonAliasesMockingSetup.DoMockingSetupForPersonAlias(1);

            mockPersonAliasesRepository.Setup(m => m.Search(It.IsAny <IPersonAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IPersonAlias> {
                mockPersonAlias.Object
            });
            mockPersonAliasesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockPersonAlias.Object);
            var businessWorkflow = new PersonAliasesBusinessWorkflow(mockPersonAliasesRepository.Object, new PersonAliasMapper());
            var model            = PersonAliasesMockingSetup.DoMockingSetupForPersonAliasModel();

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