public void MatchShouldThrowIfNoMatchFound(Func <string, bool> predicate, string value)
        {
            var pattern = new SimplePattern <string>(predicate);

            Action action = () =>
                            Match.Create <string, bool>()
                            .Case(pattern, _ => true)
                            .ExecuteOn(value);

            if (pattern.Match(value).IsSome)
            {
                action.Should().NotThrow <MatchException>();
            }
            else
            {
                action.Should().Throw <MatchException>();
            }
        }
        public Property MatchWithFallthroughShouldMatchPatternsCorrectly(Func <string, bool> predicate, string value)
        {
            var pattern = new SimplePattern <string>(predicate);

            var result = Match.Create <string, bool>(fallthroughByDefault: true)
                         .Case(pattern, _ => true)
                         .Case(Pattern.Any <string>(), _ => false)
                         .ExecuteWithFallthrough(value);

            var success = new List <bool> {
                true, false
            };
            var failure = new List <bool> {
                false
            };

            return(pattern.Match(value).IsSome
                ? result.SequenceEqual(success).ToProperty()
                : result.SequenceEqual(failure).ToProperty());
        }
        public Property NonStrictMatchToFunctionWithFallthroughTrueShouldMatchPatternsCorrectlyWithNullable(
            Func <string, bool> predicate,
            string value)
        {
            var pattern = new SimplePattern <string>(predicate);

            var result = Match.Create <string, bool?>(fallthroughByDefault: false)
                         .Case(pattern, fallthrough: true, _ => true)
                         .Case(Pattern.Any <string>(), _ => false)
                         .ToNonStrictFunctionWithFallthrough()(value);

            var success = new List <bool?> {
                true, false
            };
            var failure = new List <bool?> {
                false
            };

            return(pattern.Match(value).IsSome
                ? result.SequenceEqual(success).ToProperty()
                : result.SequenceEqual(failure).ToProperty());
        }
 public Property OperatorNotPatternShouldBeOppositeToPattern(SimplePattern <string> pattern, string x)
 => (pattern.Match(x).IsSome == (~pattern).Match(x).IsNone).ToProperty();
 public Property OperatorXorPatternShouldBeSameAsExlusiveEitherPattern(SimplePattern <string> pattern1, SimplePattern <string> pattern2, string x)
 => (pattern1.Match(x).IsSome ^ pattern2.Match(x).IsSome == (pattern1 ^ pattern2).Match(x).IsSome).ToProperty();
 public Property OrPatternShouldBeSameAsEitherPattern(SimplePattern <string> pattern1, SimplePattern <string> pattern2, string x)
 => (pattern1.Match(x).IsSome || pattern2.Match(x).IsSome == pattern1.Or(pattern2).Match(x).IsSome).ToProperty();
 public Property OperatorAndPatternShouldBeSameAsBothPatterns(SimplePattern <string> pattern1, SimplePattern <string> pattern2, string x)
 => (pattern1.Match(x).IsNone || pattern2.Match(x).IsNone == (pattern1 & pattern2).Match(x).IsNone).ToProperty();