public int Build(IFuzz fuzzy) { if (fuzzy == null) { throw new ArgumentNullException(nameof(fuzzy)); } return(fuzzy.Int32().Between(Minimum(), Maximum())); }
public FuzzyRange(IFuzz fuzz, T minimum, T maximum) : base(fuzz) { if (maximum.CompareTo(minimum) < 0) { throw new ArgumentOutOfRangeException(nameof(maximum), $"{maximum} is less than the {nameof(minimum)} value {minimum}"); } this.maximum = maximum; this.minimum = minimum; }
protected override void Given() { barMock = MockRepository.GenerateMock <IBar>(); fuzzMock = MockRepository.GenerateMock <IFuzz>(); UnderTest = new Foo(barMock, fuzzMock); barMock.Stub(x => x.BarFunction()).Return(1); }
public static Age GenerateAVerySpecificAge(this IFuzz fuzzer) { // Here, we can have access to all the existing methods // exposed by the IFuzz interface int years = fuzzer.GeneratePositiveInteger(97); // or this one (very useful) bool isConfidential = fuzzer.HeadsOrTails(); // For very specific needs, you have to use the // Random property of the Fuzzer double aDoubleForInstance = fuzzer.Random.NextDouble(); return(new Age(years, isConfidential)); }
public FuzzyChar(IFuzz fuzzy) : base(fuzzy, char.MinValue, char.MaxValue) { }
public static T[] Array <T>(this IFuzz fuzzy, Func <T> createElement, Length?length = default) => new FuzzyArray <T>(fuzzy, createElement, length ?? new Length());
public FuzzyUInt64(IFuzz fuzzy) : base(fuzzy, ulong.MinValue, ulong.MaxValue) { }
public static string String(this IFuzz fuzzy, Length length) => new FuzzyString(fuzzy, length ?? throw new ArgumentNullException(nameof(length)), null);
public static float Single(this IFuzz fuzzy) => new FuzzySingle(fuzzy);
public static long Int64(this IFuzz fuzzy) => new FuzzyInt64(fuzzy);
public static char Char(this IFuzz fuzzy) => new FuzzyChar(fuzzy);
public static byte Byte(this IFuzz fuzzy) => new FuzzyByte(fuzzy);
/// <summary> /// Instantiates a <see cref="NumberFuzzer"/>. /// </summary> /// <param name="fuzzer">Instance of <see cref="IFuzz"/> to use.</param> public NumberFuzzer(IFuzz fuzzer) { _fuzzer = fuzzer; }
public static List <T> List <T>(this IFuzz fuzzy, Func <T> createElement, Count?count = default) => new FuzzyList <T>(fuzzy, createElement, count ?? new Count());
public static List <T> List <T>(this IFuzz fuzzy, IEnumerable <T> elements, Count?count = default) => fuzzy.List(() => fuzzy.Element(elements), count);
public static short Int16(this IFuzz fuzzy) => new FuzzyInt16(fuzzy);
public static int Int32(this IFuzz fuzzy) => new FuzzyInt32(fuzzy);
public static DateTime DateTime(this IFuzz fuzzy) => new FuzzyDateTime(fuzzy);
public static sbyte SByte(this IFuzz fuzzy) => new FuzzySByte(fuzzy);
public static DateTime DateTime(this IFuzz fuzzy, DateTimeKind kind) => new FuzzyDateTime(fuzzy, kind);
public static string String(this IFuzz fuzzy) => new FuzzyString(fuzzy);
public static DateTimeOffset DateTimeOffset(this IFuzz fuzzy) => new FuzzyDateTimeOffset(fuzzy);
public static bool Boolean(this IFuzz fuzzy) => new FuzzyBoolean(fuzzy);
public static double Double(this IFuzz fuzzy) => new FuzzyDouble(fuzzy);
public static T[] Array <T>(this IFuzz fuzzy, IEnumerable <T> elements, Length?length = default) => fuzzy.Array(() => fuzzy.Element(elements), length);
public static T Element <T>(this IFuzz fuzzy, IEnumerable <T> candidates) => new FuzzyElement <T>(fuzzy, candidates);
public FuzzyByte(IFuzz fuzzy) : base(fuzzy, byte.MinValue, byte.MaxValue) { }
public static T Enum <T>(this IFuzz fuzzy) where T : Enum => new FuzzyEnum <T>(fuzzy);
const short maxExponent = 971 + 1; // +1 to allow positive and negative infinity public FuzzyDouble(IFuzz fuzzy) : base(fuzzy) { }
public static int Index <T>(this IFuzz fuzzy, IEnumerable <T> elements) => new FuzzyIndex <T>(fuzzy, elements);