private static void GenerateChildConditionMock(Or condition, bool passes) { var conditionMock = new Mock<TaskCondition>(MockBehavior.Strict); conditionMock.Setup(c => c.Evaluate(It.IsAny<TaskExecutionContext>())) .Returns(passes); condition.Children.Add(conditionMock.Object); }
public void EvaluateReturnsTrueIfAChildPasses() { var condition = new Or(); GenerateChildConditionMock(condition, true); GenerateChildConditionMock(condition, false); var contextMock = new Mock<TaskExecutionContext>(new TaskExecutionParameters()); var result = condition.Evaluate(contextMock.Object); Assert.IsTrue(result); }
public void ValidateValidatesChildren() { var condition = new Or(); var conditionMock = new Mock<TaskCondition>(MockBehavior.Strict); conditionMock.Setup(c => c.Validate(It.IsAny<IValidationLog>())).Verifiable(); condition.Children.Add(conditionMock.Object); condition.Validate(null); conditionMock.Verify(); }