public void IsMatch() { var context = CreateContext(); InvocationCondition trueCondition = _ => true; InvocationCondition falseCondition = _ => false; BuilderPatternDescriptor <InvocationExpressionSyntax> descriptor; descriptor = new BuilderPatternDescriptor <InvocationExpressionSyntax>(true); descriptor.IsMatch(context).Should().BeTrue(); descriptor = new BuilderPatternDescriptor <InvocationExpressionSyntax>(true, trueCondition); descriptor.IsMatch(context).Should().BeTrue(); descriptor = new BuilderPatternDescriptor <InvocationExpressionSyntax>(true, trueCondition, trueCondition); descriptor.IsMatch(context).Should().BeTrue(); descriptor = new BuilderPatternDescriptor <InvocationExpressionSyntax>(true, falseCondition); descriptor.IsMatch(context).Should().BeFalse(); descriptor = new BuilderPatternDescriptor <InvocationExpressionSyntax>(true, trueCondition, falseCondition); descriptor.IsMatch(context).Should().BeFalse(); }
public static InvocationCondition Or(InvocationCondition condition1, InvocationCondition condition2, InvocationCondition condition3) => (value) => condition1(value) || condition2(value) || condition3(value);
public static InvocationCondition And(InvocationCondition condition1, InvocationCondition condition2) => (value) => condition1(value) && condition2(value);
public static InvocationCondition ExceptWhen(InvocationCondition condition) => (value) => !condition(value);