コード例 #1
0
        public static Arbitrary <CborPropertyTestContext> PropertyTestInput()
        {
            Arbitrary <NonEmptyArray <CborDocument> > documentArb = Arb.Default.NonEmptyArray <CborDocument>();
            Arbitrary <bool>          convertArb       = Arb.Default.Bool();
            Gen <CborConformanceMode> conformanceModes = Gen.Elements(
                CborConformanceMode.Lax,
                CborConformanceMode.Strict,
                CborConformanceMode.Canonical,
                CborConformanceMode.Ctap2Canonical);

            Gen <CborPropertyTestContext> inputGen =
                from docs in documentArb.Generator
                from convert in convertArb.Generator
                from mode in conformanceModes
                select CborPropertyTestContextHelper.create(mode, convert, docs.Get);

            IEnumerable <CborPropertyTestContext> Shrinker(CborPropertyTestContext input)
            {
                var nonEmptyArrayInput = NonEmptyArray <CborDocument> .NewNonEmptyArray(input.RootDocuments);

                foreach (NonEmptyArray <CborDocument> shrunkDoc in documentArb.Shrinker(nonEmptyArrayInput))
                {
                    yield return(CborPropertyTestContextHelper.create(input.ConformanceMode, input.ConvertIndefiniteLengthItems, input.RootDocuments));
                }
            }

            return(Arb.From(inputGen, Shrinker));
        }
コード例 #2
0
            public Arbitrary <TelemetryGen[]> Array()
            {
                var arrayGen = Telemetry().Generator.ArrayOf();
                var arrayArb = Arb.From(arrayGen, ShrinkArray);

                IEnumerable <TelemetryGen[]> ShrinkArray(TelemetryGen[] array)
                {
                    var shrunkInstances = array.Select(y => Telemetry().Shrinker(y).ToArray());
                    var shrunkArray     = Arb.Default.NonEmptyArray <TelemetryGen>().Shrinker(NonEmptyArray <TelemetryGen> .NewNonEmptyArray(array)).Select(y => y.Item);

                    return(shrunkInstances.Concat(shrunkArray));
                }

                return(arrayArb);
            }