Пример #1
0
        public NebulaCheck.IGen <Test> IfTheImageContainsTheTargetReturnValue_ItShrinksToTheFunctionWhereTheImageIsTheTargetReturnValue() =>
        from returnValues in Gen.Int32().ListOf().WithCount(10)
        from targetReturnValue in Gen.Element(returnValues.AsEnumerable())
        from seed in DomainGen.Seed()
        from size in DomainGen.Size()
        select Property.ForThese(() =>
        {
            var variables = Enumerable.Range(0, 10);
            var gen       = GalaxyCheck.Gen.Int32().Between(0, returnValues.Count - 1).Select(i => returnValues[i]).FunctionOf <int, int>();

            var func = gen.Minimum(
                seed: seed,
                size: 100,
                pred: (f) => variables.Any(variable => f(variable) == targetReturnValue));

            variables.Should().OnlyContain(variable => func(variable) == targetReturnValue);
        });
Пример #2
0
            public static NebulaCheck.IGen <GalaxyCheck.Gen.CharType> CharType(params GalaxyCheck.Gen.CharType[] excludedCharType)
            {
                var allCharTypes = new[]
                {
                    GalaxyCheck.Gen.CharType.Whitespace,
                    GalaxyCheck.Gen.CharType.Alphabetical,
                    GalaxyCheck.Gen.CharType.Numeric,
                    GalaxyCheck.Gen.CharType.Symbol,
                    GalaxyCheck.Gen.CharType.Extended,
                    GalaxyCheck.Gen.CharType.Control
                };

                var candidateCharTypes = allCharTypes.Except(excludedCharType);

                return(Gen
                       .Element(candidateCharTypes)
                       .ListOf()
                       .WithCountGreaterThan(0)
                       .Select(xs => xs.Aggregate((GalaxyCheck.Gen.CharType) 0, (acc, curr) => acc | curr)));
            }