Exemple #1
0
 public void RandomLong(long MinValue, long MaxValue)
 {
     for (var seed = _seed; seed < (_seed + OperationsPerInvoke); seed++)
     {
         var rng = Rng.Create(seed);
         rng.Value(MinValue, MaxValue);
     }
 }
        public IGen <Test> ItInitializesTheOrder() =>
        from seed in Gen.Int32()
        select Property.ForThese(() =>
        {
            var rng = Rng.Create(seed);

            rng.Order.Should().Be(0);
        });
        public IGen <Test> ItIsRepeatable() =>
        from seed in Gen.Int32()
        select Property.ForThese(() =>
        {
            var rng0 = Rng.Create(seed);
            var rng1 = Rng.Create(seed);

            rng0.Should().BeEquivalentTo(rng1);
        });
Exemple #4
0
        public static CheckResult <T> Check <T>(
            this IGen <Test <T> > property,
            int?iterations  = null,
            int?seed        = null,
            int?size        = null,
            int?shrinkLimit = null,
            string?replay   = null,
            bool deepCheck  = true)
        {
            var resolvedIterations = iterations ?? 100;

            var(initialSize, resizeStrategy) = SizingAspects <T> .Resolve(size == null?null : new Size(size.Value), resolvedIterations);

            var initialParameters = seed == null
                ? GenParameters.Create(initialSize)
                : GenParameters.Create(Rng.Create(seed.Value), initialSize);

            var initialContext = new CheckStateContext <T>(
                property,
                resolvedIterations,
                shrinkLimit ?? 500,
                initialParameters,
                deepCheck);

            CheckState <T> initialState = replay == null
                ? new GenerationStates.Generation_Begin <T>()
                : new ReplayState <T>(replay);

            var transitions = CheckStateEnumerator.Enumerate(
                initialState,
                initialContext,
                new[] { new ResizeCheckStateTransitionDecorator <T>(resizeStrategy) });

            var transitionAggregation = AggregateTransitions(transitions);

            return(new CheckResult <T>(
                       transitionAggregation.FinalContext.CompletedIterationsUntilCounterexample,
                       transitionAggregation.FinalContext.Discards,
                       transitionAggregation.FinalContext.Shrinks + transitionAggregation.FinalContext.CompletedIterationsAfterCounterexample,
                       transitionAggregation.FinalContext.Counterexample == null
                    ? null
                    : FromCounterexampleContext(transitionAggregation.FinalContext.Counterexample),
                       transitionAggregation.Checks,
                       initialParameters,
                       transitionAggregation.FinalContext.NextParameters,
                       transitionAggregation.TerminationReason));
        }
Exemple #5
0
 private static Replay CreateReplay(int seed, int size, IEnumerable <int> exampleSpacePath) =>
 new Replay(GenParameters.Create(Rng.Create(seed), new Size(size)), exampleSpacePath);