以前の質問で、Kurtは型の設定に関するFsCheck のこのコードを教えArbitraryてくれました。
私は次のものを持っていますArbitrary(免責事項:私は自分が何をしているのかわかりません...、まだFsCheckを理解するのが難しいことで有名ですが、私はそれを機能させることに夢中です)、それ自体は私が作成したものの単純化されたバージョンですついさっき:
type MyArb() =
inherit Arbitrary<DoNotSize<int64>>()
override x.Generator = Arb.Default.DoNotSizeInt64().Generator
そして、私はそれを指示どおりに使用します:
[<Property(Verbose = true, Arbitrary= [| typeof<MyArb> |])>]
static member MultiplyIdentity (x: int64) = x * 1L = x
これにより、何かが不足しているという(やや希望に満ちた)エラーメッセージが表示されます。
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> System.Exception : No instances found on type Tests.Arithmetic.MyArb. Check that the type is public and has public static members with the right signature.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at FsCheck.Runner.checkMethod(Config config, MethodInfo m, FSharpOption`1 target) in C:\Users\Kurt\Projects\FsCheck\FsCheck\src\FsCheck\Runner.fs:line 318
at FsCheck.NUnit.Addin.FsCheckTestMethod.runTestMethod(TestResult testResult) in C:\Users\Kurt\Projects\FsCheck\FsCheck\src\FsCheck.NUnit.Addin\FsCheckTestMethod.fs:line 100
その Github コードを振り返ってみると、2 つのAtrbitraryクラスがありますが、どちらも継承されておらず、両方とも異なる静的メンバーを持っています。
乱数ジェネレーターを作成し、それを Arbitrary として静的に NUnit テストに割り当てるにはどうすればよいですか?