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();
        }
Esempio n. 2
0
 public static InvocationCondition Or(InvocationCondition condition1, InvocationCondition condition2, InvocationCondition condition3) =>
 (value) => condition1(value) || condition2(value) || condition3(value);
Esempio n. 3
0
 public static InvocationCondition And(InvocationCondition condition1, InvocationCondition condition2) =>
 (value) => condition1(value) && condition2(value);
Esempio n. 4
0
 public static InvocationCondition ExceptWhen(InvocationCondition condition) =>
 (value) => !condition(value);