public void Verify_Deactivate_ByID_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
 {
     // Arrange
     var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();
     mockTeamAliasesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => null);
     var mockTeamAliasesMapper = new Mock<ITeamAliasMapper>();
     mockTeamAliasesMapper.Setup(m => m.AreEqual(It.IsAny<ITeamAliasModel>(), It.IsAny<ITeamAlias>())).Returns(() => true);
     var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, mockTeamAliasesMapper.Object);
     // Act/Assert
     Assert.Throws<System.InvalidOperationException>(() => businessWorkflow.Deactivate(1));
 }
Esempio n. 2
0
        public void Verify_Deactivate_ByKey_ANonExistingEntity_Should_ThrowAnInvalidOperationException()
        {
            // Arrange
            var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();

            mockTeamAliasesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null);
            var mockTeamAliasesMapper = new Mock <ITeamAliasMapper>();

            mockTeamAliasesMapper.Setup(m => m.AreEqual(It.IsAny <ITeamAliasModel>(), It.IsAny <ITeamAlias>())).Returns(() => true);
            var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, mockTeamAliasesMapper.Object);

            // Act/Assert
            Assert.Throws <System.InvalidOperationException>(() => businessWorkflow.Deactivate("TEST"));
        }
Esempio n. 3
0
        public void Verify_Deactivate_ByKey_Should_DeactivateTheObjectAndReturnTrue()
        {
            // Arrange
            var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();
            var mockTeamAliasesMapper     = new Mock <ITeamAliasMapper>();

            mockTeamAliasesMapper.Setup(m => m.AreEqual(It.IsAny <ITeamAliasModel>(), It.IsAny <ITeamAlias>())).Returns(() => true);
            var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, mockTeamAliasesMapper.Object);

            mockTeamAliasesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <ITeamAlias>().Object);
            mockTeamAliasesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
            // Act
            var result = businessWorkflow.Deactivate("KING-STEPHEN");

            // Assert
            mockTeamAliasesRepository.Verify(m => m.Deactivate(It.IsAny <ITeamAlias>()), Times.Once);
            Assert.Equal(true, result);
        }
 public void Verify_Deactivate_ByID_Should_DeactivateTheObjectAndReturnTrue()
 {
     // Arrange
     var mockTeamAliasesRepository = TeamAliasesMockingSetup.DoMockingSetupForRepository();
     var mockTeamAliasesMapper = new Mock<ITeamAliasMapper>();
     mockTeamAliasesMapper.Setup(m => m.AreEqual(It.IsAny<ITeamAliasModel>(), It.IsAny<ITeamAlias>())).Returns(() => true);
     var businessWorkflow = new TeamAliasesBusinessWorkflow(mockTeamAliasesRepository.Object, mockTeamAliasesMapper.Object);
     mockTeamAliasesRepository.Setup(m => m.Get(It.IsAny<int>())).Returns(() => new Mock<ITeamAlias>().Object);
     mockTeamAliasesRepository.Setup(m => m.SaveChanges()).Returns(() => true);
     // Act
     var result = businessWorkflow.Deactivate(1);
     // Assert
     mockTeamAliasesRepository.Verify(m => m.Deactivate(It.IsAny<ITeamAlias>()), Times.Once);
     Assert.Equal(true, result);
 }