public static MinimumWithMetrics <T> MinimumWithMetrics <T>( this IGenAdvanced <T> advanced, int iterations = 100, int?seed = null, int?size = null, bool deepMinimum = false, Func <T, bool>?pred = null) { pred ??= (_) => true; var property = advanced.AsGen().ForAll(x => { var result = pred(x); return(result == false); }); var result = property.Check(iterations: iterations, seed: seed, size: size, deepCheck: deepMinimum); if (result.Falsified) { return(new MinimumWithMetrics <T>(result.Counterexample !.Value, result.Shrinks)); } throw new Exceptions.NoMinimalFoundException(); }
internal static SampleWithMetricsResult <IExampleSpace <T> > RunExampleSpaceSample <T>( IGenAdvanced <T> advanced, int?iterations, int?seed, int?size) { var property = advanced.AsGen().ForAll(_ => true); var checkResult = property.Check(iterations: iterations, seed: seed, size: size, deepCheck: false); var values = checkResult.Checks .Select(check => check.ExampleSpace) .ToList(); return(new SampleWithMetricsResult <IExampleSpace <T> >( values, checkResult.Discards, checkResult.RandomnessConsumption)); }
internal static SampleWithMetricsResult <object?[]> RunPresentationalValueSample <T>( IGenAdvanced <Test <T> > advanced, int?iterations, int?seed, int?size) { var property = advanced .AsGen() .Where(TestMeetsPrecondition) .Select(MuteTestFailure); var checkResult = property.Check(iterations: iterations, seed: seed, size: size); var values = checkResult.Checks .Select(check => check.PresentationalValue) .ToList(); return(new SampleWithMetricsResult <object?[]>( values, checkResult.Discards, checkResult.RandomnessConsumption)); }