public FsCheckRunner( IRunner runnerImplementation, FsCheckRunnerConfig csharpRunnerConfig, CSharpNotationConfig csharpNotationConfig, int?maxTest) { RunnerImplementation = runnerImplementation; FsCheckRunnerConfig = csharpRunnerConfig ?? FsCheckRunnerConfig.Default; CSharpNotationConfig = csharpNotationConfig ?? CSharpNotationConfig.Default; MaxTest = maxTest ?? FsCheckConfig.Default.MaxTest; TestTimer.Start(); }
public static string SerializeEach(IEnumerable <object> objects, CSharpNotationConfig config = null) { var context = new Context(0, config ?? CSharpNotationConfig.Default); var list = objects.ToList(); return(string.Join( $"{newLine}", list.Zip( Enumerable.Range(0, list.Count), (x, i) => { var assignmentPart = context.Config._SkipCreateAssignment ? string.Empty : list.Count == 1 ? "var data = " : $"var data{i} = "; return $"{assignmentPart}{GetCSharpString(x, context)};"; } ) )); }
/// <summary> /// Run FsCheck with using a FsCheckRunner and the given parameters. /// </summary> public static void VerboseCheckThrowOnFailure( this Property property, CSharpNotationConfig CSharpNotationConfig = null, FsCheckRunnerConfig FsCheckRunnerConfig = null, FsCheckConfig Config = null, List <Type> Arbitrary = null, int?EndSize = null, Func <int, object[], string> Every = null, Func <object[], string> EveryShrink = null, int?MaxRejected = null, int?MaxTest = null, string Name = null, ParallelRunConfig ParallelRunConfig = null, bool?QuietOnSuccess = null, Tuple <ulong, ulong, int> Replay = null, IRunner Runner = null, int?StartSize = null) { Config = Config ?? FsCheckConfig.VerboseThrowOnFailure; var csharpRunnerConfig = (FsCheckRunnerConfig ?? FsCheckRunnerConfig.Default).With(ThrowOnFailure: true); property.Verbose( Config.WithFsCheckRunner( CSharpNotationConfig, csharpRunnerConfig, Arbitrary, EndSize, Every, EveryShrink, MaxRejected, MaxTest, Name, ParallelRunConfig, QuietOnSuccess, Replay, Runner, StartSize ) ); }
/// <summary> /// Modify parameters of an FsCheck.Config instance and attach output of /// the latest shrink in CSharp notation. /// </summary> public static FsCheckConfig WithFsCheckRunner( this FsCheckConfig config, CSharpNotationConfig CSharpNotationConfig = null, FsCheckRunnerConfig FsCheckRunnerConfig = null, List <Type> Arbitrary = null, int?EndSize = null, Func <int, object[], string> Every = null, Func <object[], string> EveryShrink = null, int?MaxRejected = null, int?MaxTest = null, string Name = null, ParallelRunConfig ParallelRunConfig = null, bool?QuietOnSuccess = null, Tuple <ulong, ulong, int> Replay = null, IRunner Runner = null, int?StartSize = null) { var runner = Runner; var csharpRunnerConfig = FsCheckRunnerConfig; var csharpNotationConfig = CSharpNotationConfig; if (runner == null) { runner = config.Runner; } if (runner is FsCheckRunner csharpRunner) { // Unwrap allows us to call WithFsCheckRunner multiple times without a problem. runner = csharpRunner.RunnerImplementation; // Preserve wrapped runner configs unless method parameters were set. if (FsCheckRunnerConfig == null) { csharpRunnerConfig = csharpRunner.FsCheckRunnerConfig; } if (CSharpNotationConfig == null) { csharpNotationConfig = csharpRunner.CSharpNotationConfig; } } return(config.With( Arbitrary: Arbitrary, EndSize: EndSize, Every: Every, EveryShrink: EveryShrink, MaxRejected: MaxRejected, MaxTest: MaxTest, Name: Name, ParallelRunConfig: ParallelRunConfig, QuietOnSuccess: QuietOnSuccess, Replay: Replay, Runner: new FsCheckRunner( runnerImplementation: runner, csharpRunnerConfig: csharpRunnerConfig, csharpNotationConfig: csharpNotationConfig, maxTest: MaxTest ?? config.MaxTest ), StartSize: StartSize )); }
public static string Serialize(object item, CSharpNotationConfig config = null) { return(SerializeEach(new[] { item }, config)); }
private Context With(int?IndentLevel = null, CSharpNotationConfig Config = null) { return(new Context(IndentLevel ?? this.IndentLevel, Config ?? this.Config)); }
public Context(int IndentLevel, CSharpNotationConfig Config) { this.IndentLevel = IndentLevel; this.Config = Config; }