public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockCharacterCreatorsRepository = CharacterCreatorsMockingSetup.DoMockingSetupForRepository();
     mockCharacterCreatorsRepository.Setup(m => m.Search(It.IsAny<ICharacterCreatorSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<ICharacterCreator>>().Object);
     var businessWorkflow = new CharacterCreatorsBusinessWorkflow(mockCharacterCreatorsRepository.Object, new CharacterCreatorMapper());
     var model = CharacterCreatorsMockingSetup.DoMockingSetupForCharacterCreatorModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockCharacterCreatorsRepository.Verify(m => m.Add(It.IsAny<ICharacterCreator>()), Times.Once);
 }
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockCharacterCreatorsRepository = CharacterCreatorsMockingSetup.DoMockingSetupForRepository();

            mockCharacterCreatorsRepository.Setup(m => m.Search(It.IsAny <ICharacterCreatorSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <ICharacterCreator> >().Object);
            var businessWorkflow = new CharacterCreatorsBusinessWorkflow(mockCharacterCreatorsRepository.Object, new CharacterCreatorMapper());
            var model            = CharacterCreatorsMockingSetup.DoMockingSetupForCharacterCreatorModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockCharacterCreatorsRepository.Verify(m => m.Add(It.IsAny <ICharacterCreator>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockCharacterCreatorsRepository = CharacterCreatorsMockingSetup.DoMockingSetupForRepository();
     var mockCharacterCreator = CharacterCreatorsMockingSetup.DoMockingSetupForCharacterCreator(1);
     mockCharacterCreatorsRepository.Setup(m => m.Search(It.IsAny<ICharacterCreatorSearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<ICharacterCreator> { mockCharacterCreator.Object } );
     mockCharacterCreatorsRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockCharacterCreator.Object);
     var businessWorkflow = new CharacterCreatorsBusinessWorkflow(mockCharacterCreatorsRepository.Object, new CharacterCreatorMapper());
     var model = CharacterCreatorsMockingSetup.DoMockingSetupForCharacterCreatorModel();
     // 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
     mockCharacterCreatorsRepository.Verify(m => m.Add(It.IsAny<ICharacterCreator>()), Times.Never);
 }
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockCharacterCreatorsRepository = CharacterCreatorsMockingSetup.DoMockingSetupForRepository();
            var mockCharacterCreator            = CharacterCreatorsMockingSetup.DoMockingSetupForCharacterCreator(1);

            mockCharacterCreatorsRepository.Setup(m => m.Search(It.IsAny <ICharacterCreatorSearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <ICharacterCreator> {
                mockCharacterCreator.Object
            });
            mockCharacterCreatorsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockCharacterCreator.Object);
            var businessWorkflow = new CharacterCreatorsBusinessWorkflow(mockCharacterCreatorsRepository.Object, new CharacterCreatorMapper());
            var model            = CharacterCreatorsMockingSetup.DoMockingSetupForCharacterCreatorModel();

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