public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockConceptIssuesRepository = ConceptIssuesMockingSetup.DoMockingSetupForRepository(); mockConceptIssuesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new ConceptIssuesBusinessWorkflow(mockConceptIssuesRepository.Object, new ConceptIssueMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockConceptIssuesRepository = ConceptIssuesMockingSetup.DoMockingSetupForRepository(); var mockConceptIssuesMapper = new Mock <IConceptIssueMapper>(); mockConceptIssuesMapper.Setup(m => m.AreEqual(It.IsAny <IConceptIssueModel>(), It.IsAny <IConceptIssue>())).Returns(() => true); var businessWorkflow = new ConceptIssuesBusinessWorkflow(mockConceptIssuesRepository.Object, mockConceptIssuesMapper.Object); mockConceptIssuesRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <IConceptIssue>().Object); mockConceptIssuesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockConceptIssuesRepository.Verify(m => m.Remove(It.IsAny <IConceptIssue>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockConceptIssuesRepository = ConceptIssuesMockingSetup.DoMockingSetupForRepository(); var mockConceptIssuesMapper = new Mock<IConceptIssueMapper>(); mockConceptIssuesMapper.Setup(m => m.AreEqual(It.IsAny<IConceptIssueModel>(), It.IsAny<IConceptIssue>())).Returns(() => true); var businessWorkflow = new ConceptIssuesBusinessWorkflow(mockConceptIssuesRepository.Object, mockConceptIssuesMapper.Object); mockConceptIssuesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<IConceptIssue>().Object); mockConceptIssuesRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockConceptIssuesRepository.Verify(m => m.Remove(It.IsAny<IConceptIssue>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockConceptIssuesRepository = ConceptIssuesMockingSetup.DoMockingSetupForRepository(); mockConceptIssuesRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new ConceptIssuesBusinessWorkflow(mockConceptIssuesRepository.Object, new ConceptIssueMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }