Adf.Test.Domain.DomainObjectTestExtensions.GenerateNumeric C# (CSharp) Method

GenerateNumeric() private static method

private static GenerateNumeric ( PropertyInfo propertyInfo ) : object
propertyInfo System.Reflection.PropertyInfo
return object
        private static object GenerateNumeric(PropertyInfo propertyInfo)
        {
            var attrs = (InRangeAttribute[]) propertyInfo.GetCustomAttributes(typeof (InRangeAttribute), false);
            int value = attrs.Length > 0 ? new Random().Next(Convert.ToInt32(attrs[0].Min), Convert.ToInt32(attrs[0].Max)) : 1;

            Type t = propertyInfo.PropertyType;
            if (t.IsNullable()) t = Nullable.GetUnderlyingType(t);

            if (t == typeof(uint)) return (uint) value;
            if (t == typeof(short)) return (short) value;
            if (t == typeof(ushort)) return (ushort) value;
            if (t == typeof(long)) return (long) value;
            if (t == typeof(ulong)) return (ulong) value;

            return value;
        }