public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockPowerAliasesRepository = PowerAliasesMockingSetup.DoMockingSetupForRepository();
     mockPowerAliasesRepository.Setup(m => m.Search(It.IsAny<IPowerAliasSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<IPowerAlias>>().Object);
     var businessWorkflow = new PowerAliasesBusinessWorkflow(mockPowerAliasesRepository.Object, new PowerAliasMapper());
     var model = PowerAliasesMockingSetup.DoMockingSetupForPowerAliasModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockPowerAliasesRepository.Verify(m => m.Add(It.IsAny<IPowerAlias>()), Times.Once);
 }
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockPowerAliasesRepository = PowerAliasesMockingSetup.DoMockingSetupForRepository();

            mockPowerAliasesRepository.Setup(m => m.Search(It.IsAny <IPowerAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <IPowerAlias> >().Object);
            var businessWorkflow = new PowerAliasesBusinessWorkflow(mockPowerAliasesRepository.Object, new PowerAliasMapper());
            var model            = PowerAliasesMockingSetup.DoMockingSetupForPowerAliasModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockPowerAliasesRepository.Verify(m => m.Add(It.IsAny <IPowerAlias>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockPowerAliasesRepository = PowerAliasesMockingSetup.DoMockingSetupForRepository();
     var mockPowerAlias = PowerAliasesMockingSetup.DoMockingSetupForPowerAlias(1);
     mockPowerAliasesRepository.Setup(m => m.Search(It.IsAny<IPowerAliasSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<IPowerAlias> { mockPowerAlias.Object } );
     mockPowerAliasesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockPowerAlias.Object);
     var businessWorkflow = new PowerAliasesBusinessWorkflow(mockPowerAliasesRepository.Object, new PowerAliasMapper());
     var model = PowerAliasesMockingSetup.DoMockingSetupForPowerAliasModel();
     // 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
     mockPowerAliasesRepository.Verify(m => m.Add(It.IsAny<IPowerAlias>()), Times.Never);
 }
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockPowerAliasesRepository = PowerAliasesMockingSetup.DoMockingSetupForRepository();
            var mockPowerAlias             = PowerAliasesMockingSetup.DoMockingSetupForPowerAlias(1);

            mockPowerAliasesRepository.Setup(m => m.Search(It.IsAny <IPowerAliasSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <IPowerAlias> {
                mockPowerAlias.Object
            });
            mockPowerAliasesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockPowerAlias.Object);
            var businessWorkflow = new PowerAliasesBusinessWorkflow(mockPowerAliasesRepository.Object, new PowerAliasMapper());
            var model            = PowerAliasesMockingSetup.DoMockingSetupForPowerAliasModel();

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