public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
 {
     // Arrange
     var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();
     mockCharacterEnemiesRepository.Setup(m => m.Search(It.IsAny<ICharacterEnemySearchModel>(), It.IsAny<bool>()))
         .Returns(() => new Mock<List<ICharacterEnemy>>().Object);
     var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, new CharacterEnemyMapper());
     var model = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemyModel();
     // Act
     try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
     // Assert
     mockCharacterEnemiesRepository.Verify(m => m.Add(It.IsAny<ICharacterEnemy>()), Times.Once);
 }
示例#2
0
        public void Verify_Create_Should_AddANewEntityObjectToTheDatabase()
        {
            // Arrange
            var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();

            mockCharacterEnemiesRepository.Setup(m => m.Search(It.IsAny <ICharacterEnemySearchModel>(), It.IsAny <bool>()))
            .Returns(() => new Mock <List <ICharacterEnemy> >().Object);
            var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, new CharacterEnemyMapper());
            var model            = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemyModel();

            // Act
            try { businessWorkflow.Create(model.Object); } catch { /* Ignored */ }
            // Assert
            mockCharacterEnemiesRepository.Verify(m => m.Add(It.IsAny <ICharacterEnemy>()), Times.Once);
        }
 public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
 {
     // Arrange
     var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();
     var mockCharacterEnemy = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemy(1);
     mockCharacterEnemiesRepository.Setup(m => m.Search(It.IsAny<ICharacterEnemySearchModel>(), It.IsAny<bool>()))
         .Returns(() => new List<ICharacterEnemy> { mockCharacterEnemy.Object } );
     mockCharacterEnemiesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => mockCharacterEnemy.Object);
     var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, new CharacterEnemyMapper());
     var model = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemyModel();
     // 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
     mockCharacterEnemiesRepository.Verify(m => m.Add(It.IsAny<ICharacterEnemy>()), Times.Never);
 }
示例#4
0
        public void Verify_Create_WithDuplicateData_Should_NotAddAndReturnOriginal()
        {
            // Arrange
            var mockCharacterEnemiesRepository = CharacterEnemiesMockingSetup.DoMockingSetupForRepository();
            var mockCharacterEnemy             = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemy(1);

            mockCharacterEnemiesRepository.Setup(m => m.Search(It.IsAny <ICharacterEnemySearchModel>(), It.IsAny <bool>()))
            .Returns(() => new List <ICharacterEnemy> {
                mockCharacterEnemy.Object
            });
            mockCharacterEnemiesRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => mockCharacterEnemy.Object);
            var businessWorkflow = new CharacterEnemiesBusinessWorkflow(mockCharacterEnemiesRepository.Object, new CharacterEnemyMapper());
            var model            = CharacterEnemiesMockingSetup.DoMockingSetupForCharacterEnemyModel();

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