public IList <TValue> CreateMany <TValue>( int numberOfObjects, int maxRecursionDepth = 2, IFastMemberWithValues member = null) { return(CreateMany(typeof(TValue), numberOfObjects, maxRecursionDepth, member).CastOrDefault <TValue>().ToList()); }
public IList <TCompoundValue> CreateMany <TCompoundValue> ( int numberOfObjects, int maxRecursionDepth = 2, IFastMemberWithValues member = null) { throw new NotSupportedException(); }
public IKey CreateKey(IFastMemberWithValues member) { return(new ChainedKey(_declaringType, new List <MemberKeyPart> (_memberChain) { new MemberKeyPart(member) })); }
public static RangeContstraints <T> FromMember([CanBeNull] IFastMemberWithValues member) { if (member == null) { return(null); } if (!member.IsDefined(typeof(RangeAttribute))) { return(null); } var rangeAttribute = member.GetCustomAttribute <RangeAttribute>(); if (rangeAttribute == null) { return(null); } if (rangeAttribute.OperandType != typeof(T)) { return(null); } var minValue = (T)Convert.ChangeType(rangeAttribute.Minimum, typeof(T)); var maxValue = (T)Convert.ChangeType(rangeAttribute.Maximum, typeof(T)); if ((minValue).CompareTo(maxValue) > 0) { throw new ArgumentOutOfRangeException( string.Format("On the member {0} {1} the Range attribute has an invalid range", member.Type, member.Name)); } return(new RangeContstraints <T> (minValue, maxValue)); }
protected internal ValueProviderObjectContext( ITestDataGenerator testDataGenerator, Func <object, object> getPreviousValue, Type targetValueType, AdvancedContext advanced, [CanBeNull] IFastMemberWithValues member) { TestDataGenerator = testDataGenerator; Random = testDataGenerator.Random; GetPreviousValue = getPreviousValue; TargetValueType = targetValueType; Advanced = advanced; Member = member; }
public object Create(Type type, int maxRecursionDepth = 2, IFastMemberWithValues member = null) { throw new NotSupportedException(); }
public TCompoundValue Create <TCompoundValue> (int maxRecursionDepth = 2, IFastMemberWithValues member = null) { throw new NotSupportedException(); }
static void CompareMember(IFastMemberWithValues member, KeyValuePair <Type, string> property) { member.Type.Should().Be(property.Key); member.Name.Should().Be(property.Value); }
public IKey CreateKey(IFastMemberWithValues member) { return(new ChainedKey(_type, new List <MemberKeyPart> { new MemberKeyPart(member) })); }
internal MemberKeyPart(IFastMemberWithValues member, Type concreteType = null) { Member = member; MemberType = concreteType ?? Member.Type; }
public TValue Create <TValue>(int maxRecursionDepth = 2, IFastMemberWithValues member = null) { return((TValue)Create(typeof(TValue), maxRecursionDepth, member)); }
internal ModificationContext(Type memberType, [CanBeNull] IFastMemberWithValues member, IRandom random) { MemberType = memberType; Member = member; Random = random; }
internal ChainedKey(Type declaringType, IFastMemberWithValues member) : this(declaringType, new List <MemberKeyPart> { new MemberKeyPart(member) }) { }
public IList <object> CreateMany(Type type, int numberOfObjects, int maxRecursionDepth = 2, IFastMemberWithValues member = null) { var rootKey = member == null ? (IKey) new TypeKey(type) : new ChainedKey(type, member); return(CreateMany(rootKey, null, numberOfObjects, maxRecursionDepth)); }
public object Create(Type type, int maxRecursionDepth = 2, IFastMemberWithValues member = null) { return(CreateMany(type, 1, maxRecursionDepth, member).Single()); }
public IList <object> CreateMany(Type type, int numberOfObjects, int maxRecursionDepth = 2, IFastMemberWithValues member = null) { throw new NotSupportedException(); }
public IKey CreateKey(IFastMemberWithValues member) { throw new NotSupportedException(); }
public static StringConstraints FromMember([CanBeNull] IFastMemberWithValues member) { if (member == null) { return(null); } var minLength = -1; var maxLength = -1; var minLengthDefined = false; var maxLengthDefined = false; if (member.IsDefined(typeof(MinLengthAttribute))) { var minLengthAttribute = member.GetCustomAttribute <MinLengthAttribute>(); minLength = minLengthAttribute?.Length ?? 0; minLengthDefined = true; } if (member.IsDefined(typeof(MaxLengthAttribute))) { var maxLengthAttribute = member.GetCustomAttribute <MaxLengthAttribute>(); maxLength = maxLengthAttribute?.Length ?? 0; maxLengthDefined = true; } if (minLengthDefined && maxLengthDefined && maxLength < minLength) { throw new ArgumentOutOfRangeException( string.Format( "On the member {0} {1} the MinLength attribute and MaxLength attribute result in an invalid range", member.Type, member.Name)); } if (member.IsDefined(typeof(StringLengthAttribute))) { var stringLengthAttribute = member.GetCustomAttribute <StringLengthAttribute>(); minLength = stringLengthAttribute?.MinimumLength ?? 0; maxLength = stringLengthAttribute?.MaximumLength ?? 0; if (maxLength < minLength) { throw new ArgumentOutOfRangeException( string.Format("On the member {0} {1} the StringLength attribute has an invalid range", member.Type, member.Name)); } } if (minLength < 0 && maxLength < 0) { return(null); } if (minLengthDefined && !maxLengthDefined) { maxLength = minLength + 100; } if (maxLengthDefined && !minLengthDefined) { minLength = maxLength - 100; } if (minLength < 0) { minLength = 0; } return(new StringConstraints(minLength, maxLength)); }