public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository(); mockTeamsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => null); var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, new TeamMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository(); var mockTeamsMapper = new Mock <ITeamMapper>(); mockTeamsMapper.Setup(m => m.AreEqual(It.IsAny <ITeamModel>(), It.IsAny <ITeam>())).Returns(() => true); var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, mockTeamsMapper.Object); mockTeamsRepository.Setup(m => m.Get(It.IsAny <string>())).Returns(() => new Mock <ITeam>().Object); mockTeamsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockTeamsRepository.Verify(m => m.Remove(It.IsAny <ITeam>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ByKey_Should_DeactivateTheObjectAndReturnTrue() { // Arrange var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository(); var mockTeamsMapper = new Mock<ITeamMapper>(); mockTeamsMapper.Setup(m => m.AreEqual(It.IsAny<ITeamModel>(), It.IsAny<ITeam>())).Returns(() => true); var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, mockTeamsMapper.Object); mockTeamsRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => new Mock<ITeam>().Object); mockTeamsRepository.Setup(m => m.SaveChanges()).Returns(() => true); // Act var result = businessWorkflow.Remove("KING-STEPHEN"); // Assert mockTeamsRepository.Verify(m => m.Remove(It.IsAny<ITeam>()), Times.Once); Assert.Equal(true, result); }
public void Verify_Remove_ANonExistingEntity_Should_ReturnTrue() { // Arrange var mockTeamsRepository = TeamsMockingSetup.DoMockingSetupForRepository(); mockTeamsRepository.Setup(m => m.Get(It.IsAny<string>())).Returns(() => null); var businessWorkflow = new TeamsBusinessWorkflow(mockTeamsRepository.Object, new TeamMapper()); // Act var result = businessWorkflow.Remove("DOESNT-EXIST"); // Assert Assert.Equal(true, result); }