コード例 #1
0
 public NebulaCheck.IGen <Test> ItProducesValuesLikeInt32() =>
 from min in Gen.Int16()
 from max in Gen.Int16().GreaterThanEqual(min)
 from origin in Gen.Int16().Between(min, max)
 from bias in DomainGen.Bias()
 from seed in DomainGen.Seed()
 from size in DomainGen.Size()
 select Property.ForThese(() =>
 {
コード例 #2
0
        public NebulaCheck.IGen <Test> ItShrinksToTheOrigin() =>
        from bias in DomainGen.Bias()
        from origin in Gen.Int64()
        from seed in DomainGen.Seed()
        select Property.ForThese(() =>
        {
            var gen = GalaxyCheck.Gen.Int64().WithBias(bias).ShrinkTowards(origin);

            var minimum = gen.Minimum(seed: seed);

            minimum.Should().Be(origin);
        });
コード例 #3
0
        public NebulaCheck.IGen <Test> ItShrinksToTheSinglePredicatedElement() =>
        from bias in DomainGen.Bias()
        from elementMinimum in Gen.Int32().Between(0, 100)
        from seed in DomainGen.Seed()
        select Property.ForThese(() =>
        {
            var gen = GalaxyCheck.Gen.Int32().Between(0, 100).ListOf();

            var minimum = gen.Minimum(seed: seed, pred: list => list.Any(element => element >= elementMinimum));

            minimum.Should().BeEquivalentTo(elementMinimum);
        });
コード例 #4
0
        public NebulaCheck.IGen <Test> ItShrinksToTheLocalMinimum_ForANegativeRange() =>
        from bias in DomainGen.Bias()
        from origin in Gen.Int64().Between(0, -100)
        from localMin in Gen.Int64().Between(origin, -200)
        from seed in DomainGen.Seed()
        select Property.ForThese(() =>
        {
            var gen = GalaxyCheck.Gen.Int64().WithBias(bias).ShrinkTowards(origin);

            var minimum = gen.Minimum(seed: seed, pred: value => value <= localMin);

            minimum.Should().Be(localMin);
        });
コード例 #5
0
        public NebulaCheck.IGen <Test> ItShrinksTheCountToTheLocalMinimumCount() =>
        from bias in DomainGen.Bias()
        from elementGen in DomainGen.Gen()
        from localMinCount in Gen.Int32().Between(0, 5)
        from seed in DomainGen.Seed()
        select Property.ForThese(() =>
        {
            var gen = GalaxyCheck.Gen.List(elementGen);

            var minimum = gen.Minimum(seed: seed, pred: list => list.Count >= localMinCount);

            minimum.Should().HaveCount(localMinCount);
        });
コード例 #6
0
        public NebulaCheck.IGen <Test> ItShrinksAnyScenarioWithin128Attempts_ForANegativeRange() =>
        from bias in DomainGen.Bias().NoShrink()
        from localMin in Gen.Int64().Between(0, long.MinValue / 2).NoShrink()
        from seed in DomainGen.Seed()
        select Property.ForThese(() =>
        {
            var gen = GalaxyCheck.Gen.Int64().LessThanEqual(0).WithBias(bias);

            var minimum = gen.Advanced.MinimumWithMetrics(
                seed: seed,
                deepMinimum: false,
                pred: value => value <= localMin);

            minimum.Shrinks.Should().BeLessOrEqualTo(128);
        });
コード例 #7
0
        public NebulaCheck.IGen <Test> ItShrinksTheCountToTheMinimumCountWhilstShrinkingTheElementsToTheirMinimums() =>
        from bias in DomainGen.Bias()
        from elementGen in DomainGen.Gen()
        from minCount in Gen.Int32().Between(0, 20)
        from seed in DomainGen.Seed()
        select Property.ForThese(() =>
        {
            var elementMinimum = elementGen.Minimum(seed: seed);
            var gen            = GalaxyCheck.Gen.List(elementGen).WithCountGreaterThanEqual(minCount);

            var minimum = gen.Minimum(seed: seed);

            minimum.Should()
            .HaveCount(minCount).And
            .AllBeEquivalentTo(elementMinimum);
        });