Just started looking at FsCheck, wrote several tests, and now I am wondering what is a good strategy for composing more complex arbitraries. Is registering arbitraries within arbitrary good approach? Something like this
public class DiscountAmountArbitrator
{
public static Arbitrary<DiscountAmount> DiscountAmounts()
{
Arb.Register<AmountArbitrary>();
var toReturn = (from a in Arb.Generate<Amount>()
select new DiscountAmount(a))
.ToArbitrary();
return toReturn;
}
}
public class AmountArbitrary
{
public static Arbitrary<Amount> Amounts()
{
return Arb.Generate<decimal>().Where(x => x > 0)
.Select(x => new Amount(x))
.ToArbitrary();
}
}