public static Arbitrary <Money <T> > Get <T>() where T : IEquatable <T> { var gen = from money in MoneyGenerators.Generator <T>() where money != null select money; return(Arb.From(gen, MoneyGenerators.Shrinker)); }
private static IEnumerable <SameCurrency <T> > Shrinker <T>(SameCurrency <T> x) where T : IEquatable <T> { if (x == null) { yield break; } using (var first = MoneyGenerators.Shrinker(x.First).GetEnumerator()) using (var second = MoneyGenerators.Shrinker(x.Second).GetEnumerator()) using (var third = MoneyGenerators.Shrinker(x.Third).GetEnumerator()) { while (first.MoveNext() && second.MoveNext() && third.MoveNext()) { yield return(new SameCurrency <T>( first.Current, second.Current, third.Current)); } } }
public static Arbitrary <Money <T> > Get <T>() where T : IEquatable <T> => Arb.From(MoneyGenerators.Generator <T>(), MoneyGenerators.Shrinker);