public NebulaCheck.IGen <Test> ItErrorsWhenMinimumLengthIsGreaterThanMaximumLength() => from minLength in Gen.Int32().Between(1, 100) from maxLength in Gen.Int32().GreaterThanEqual(0).LessThan(minLength) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => {
public NebulaCheck.IGen <Test> IfThereIsOneChoice_ItProducesValuesLikeTheSource() => from choiceGen in DomainGen.Gen() from choiceWeight in Gen.Int32().GreaterThan(1) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => {
public NebulaCheck.IGen <Test> ItProducesValuesLikeList() => from elementGen in DomainGen.Gen() from count in Gen.Int32().Between(0, 20) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => {
public NebulaCheck.IGen <Test> ItHasACountLimitEnabledByDefault() => from seed in DomainGen.Seed() from size in DomainGen.Size() from elementGen in DomainGen.Gen() from excessiveCount in Gen.Int32().Between(1001, 2000) select Property.ForThese(() => {
public NebulaCheck.IGen <Test> ItErrorsWhenMinimumCountIsGreaterThanMaximumCount() => from seed in DomainGen.Seed() from size in DomainGen.Size() from elementGen in DomainGen.Gen() from minCount in Gen.Int32().Between(1, 20) from maxCount in Gen.Int32().GreaterThanEqual(0).LessThan(minCount) select Property.ForThese(() => {
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(() => {
public NebulaCheck.IGen <Test> ItOnlyCallsThePropertyFunctionOnce() => from gen in DomainGen.Gen() from func in Gen.Function <object, bool>(Gen.Boolean()) from seed in Gen.Int32() let property0 = gen.ForAll(func) let result0 = property0.Check(seed: seed) where result0.Falsified select Property.ForThese(() => {
public NebulaCheck.IGen <Test> GreaterThanDefersToUnderlyingMethod() => from minExclusive in Gen.Int32().LessThan(int.MaxValue) select Property.ForThese(() => { var mockGen = SetupMock(); mockGen.Object.GreaterThan(minExclusive); mockGen.Verify(gen => gen.GreaterThanEqual(minExclusive + 1), Times.Once); });
public NebulaCheck.IGen <Test> LessThanDefersToUnderlyingMethod() => from maxExclusive in Gen.Byte().GreaterThan(byte.MinValue) select Property.ForThese(() => { var mockGen = SetupMock(); mockGen.Object.LessThan(maxExclusive); mockGen.Verify(gen => gen.LessThanEqual((byte)(maxExclusive - 1)), Times.Once); });
public NebulaCheck.IGen <Test> GreaterThanLengthDefersToUnderlyingMethod() => from minLengthExclusive in Gen.Int32() select Property.ForThese(() => { var mockGen = SetupMock(); mockGen.Object.WithLengthGreaterThan(minLengthExclusive); mockGen.Verify(gen => gen.WithLengthGreaterThanEqual(minLengthExclusive + 1), Times.Once); });
public NebulaCheck.IGen <Test> LessThanCountDefersToUnderlyingMethod() => from maxCountExclusive in Gen.Int32() select Property.ForThese(() => { var mockGen = SetupMock(); mockGen.Object.WithCountLessThan(maxCountExclusive); mockGen.Verify(gen => gen.WithCountLessThanEqual(maxCountExclusive - 1), Times.Once); });
public NebulaCheck.IGen <Test> ItIsAffectedByItsArgument() => from variables in Gen.Int32().WithBias(Gen.Bias.None).Two().ListOf().WithCount(10) from seed in DomainGen.Seed() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.Int32().FunctionOf <object, int>(); var func = gen.SampleOne(seed: seed, size: 100); variables.Should().Contain(variable => func(variable.Item1) != func(variable.Item2)); });
public NebulaCheck.IGen <Test> ItProducesValuesLessThanOrEqualMaximum() => from max in Gen.Int64() from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.Int64().LessThanEqual(max); var exampleSpace = gen.Advanced.SampleOneExampleSpace(seed: seed, size: size); exampleSpace.Traverse().Take(100).Should().OnlyContain(value => value <= max); });
public NebulaCheck.IGen <Test> IfTheShrinkLimitIsZero_ThePropertyCanStillBeFalsified() => from gen in DomainGen.Gen() from shrinkLimit in Gen.Int32().LessThanEqual(0) from seed in DomainGen.Seed() select Property.ForThese(() => { var property = gen.ForAll(_ => false); var result = property.Check(seed: seed, shrinkLimit: shrinkLimit); result.Falsified.Should().BeTrue(); });
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); });
public static NebulaCheck.IGen <Test> ItReportsTheNumberOfTimesTheGenCouldShrink() => from gen in DomainGen.Gen() from numberOfShrinks in Gen.Int32().Between(0, 100) from seed in DomainGen.Seed() select Property.ForThese(() => { var minimum = gen .Unfold(x => UnfoldToNumberOfShrinks(x, numberOfShrinks)) .Advanced.MinimumWithMetrics(seed: seed); minimum.Shrinks.Should().Be(numberOfShrinks); });
public NebulaCheck.IGen <Test> ItShrinksToTheGivenLimit() => from shrinkLimit in Gen.Int32().Between(0, 100) from seed in DomainGen.Seed() select Property.ForThese(() => { var property = InfinitelyShrinkableGen.ForAll(_ => false); var result = property.Check(seed: seed, shrinkLimit: shrinkLimit); result.Shrinks.Should().Be(shrinkLimit); result.TerminationReason.Should().Be(TerminationReason.ReachedShrinkLimit); });
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); });
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); });
public NebulaCheck.IGen <Test> IfSizeIsBelowChaosSize_AndRangeIsZero_ItDoesNotConsumeRandomness() => from seed in DomainGen.Seed() from size in DomainGen.Size(allowChaos: false) from iterations in DomainGen.Iterations() from x in Gen.Int64() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.Int64().Between(x, x); var sample = gen.Advanced.SampleWithMetrics(iterations: iterations, seed: seed, size: size); sample.RandomnessConsumption.Should().Be(0); });
public NebulaCheck.IGen <Test> ItProducesValuesWithOfTheSpecificCount() => from elementGen in DomainGen.Gen() from count in Gen.Int32().Between(0, 20) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = elementGen.ListOf().WithCount(count); var exampleSpace = gen.Advanced.SampleOneExampleSpace(seed: seed, size: size); exampleSpace.Traverse().Take(100).Should().OnlyContain(value => value.Count == count); });
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); });
public NebulaCheck.IGen <Test> AGeneratedEnumerableHasTheGivenLimit() => from elementGen in DomainGen.Gen() from limit in Gen.Int32().Between(1, 1000) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = elementGen.InfiniteOf(iterationLimit: limit).Select(EnsureSourceCanShrink); var sample = gen.Advanced.SampleOneExampleSpace(seed: seed, size: size); AssertLimit(sample, limit); });
public NebulaCheck.IGen <Test> ItProducesValuesWithinTheGivenDates() => from seed in DomainGen.Seed() from size in DomainGen.Size() from fromDateTime in Gen.DateTime() from untilDateTime in Gen.DateTime().From(fromDateTime) select Property.ForThese(() => { var gen = GalaxyCheck.Gen.DateTime().From(fromDateTime).Until(untilDateTime); var sample = gen.SampleOneTraversal(seed: seed, size: size); sample.Should().OnlyContain(dt => fromDateTime <= dt && dt <= untilDateTime); });
public NebulaCheck.IGen <Test> ItProducesDistinctValuesWithOfTheSpecificCount() => from count in Gen.Int32().Between(0, 20) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var elementGen = GalaxyCheck.Gen.Int32(); var gen = elementGen.SetOf().WithCount(count); var sample = gen.SampleOneTraversal(seed: seed, size: size); sample.Should().OnlyContain(set => set.Count == count && set.Distinct().SequenceEqual(set)); });
public NebulaCheck.IGen <Test> IfTheReplayIsInAnInvalidFormat_ItThrows() => from gen in DomainGen.Gen() from func in Gen.Function <object, bool>(Gen.Boolean()) from replay in Gen.Constant("0") select Property.ForThese(() => { var property = gen.ForAll(func); Action test = () => property.Check(replay: replay); test.Should() .Throw <GalaxyCheck.Exceptions.GenErrorException>() .WithMessage("Error decoding replay string:*"); });
public NebulaCheck.IGen <Test> ItErrorsWhenTheMaximumLengthIsNegative() => from maxLength in Gen.Int32().LessThan(0) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.String().WithLengthLessThanEqual(maxLength); Action action = () => gen.SampleOne(seed: seed, size: size); action.Should() .Throw <GalaxyCheck.Exceptions.GenErrorException>() .WithMessage("Error while running generator StringGen: 'maxLength' cannot be negative"); });
public NebulaCheck.IGen <Test> IfSizeIsBelowChaosSize_AndCountIsSpecific_ItConsumesRandomnessForEachElement() => from seed in DomainGen.Seed() from size in DomainGen.Size(allowChaos: false) from elementGen in DomainGen.Gen() from count in Gen.Int32().Between(0, 20) select Property.ForThese(() => { var gen = elementGen.ListOf().WithCount(count); var listSample = gen.Advanced.SampleOneWithMetrics(seed: seed, size: size); var elementSample = elementGen.Advanced.SampleWithMetrics(iterations: listSample.Value.Count, seed: seed, size: size); listSample.RandomnessConsumption.Should().Be(elementSample.RandomnessConsumption); });
public NebulaCheck.IGen <Test> ItErrorsWhenMaximumIsLessThanOrigin() => from max in Gen.Int64().LessThan(long.MaxValue) from origin in Gen.Int64().GreaterThan(max) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.Int64().LessThanEqual(max).ShrinkTowards(origin); Action action = () => gen.SampleOne(seed: seed, size: size); action.Should() .Throw <GalaxyCheck.Exceptions.GenErrorException>() .WithMessage("Error while running generator Int64: 'origin' must be between 'min' and 'max'"); });
public NebulaCheck.IGen <Test> ItErrorsWhenMinimumIsGreaterThanMaximum() => from min in Gen.Int64().GreaterThan(long.MinValue) from max in Gen.Int64().LessThan(min) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.Int64().GreaterThanEqual(min).LessThanEqual(max); Action action = () => gen.SampleOne(seed: seed, size: size); action.Should() .Throw <GalaxyCheck.Exceptions.GenErrorException>() .WithMessage("Error while running generator Int64: 'min' cannot be greater than 'max'"); });