예제 #1
0
        public static string GenColumn(this Random r, CsvColumnType type)
        {
            switch (type)
            {
            case CsvColumnType.Integer:
                return(r.Next().ToString());

            case CsvColumnType.ShortString:
                return(r.RandomString(1 + r.Next(4)));

            case CsvColumnType.LongString:
                return(r.RandomString(20 + r.Next(10)));

            case CsvColumnType.Char:
                return(r.Char().ToString());

            case CsvColumnType.Date:
                return(DateTime.Today.AddDays(r.Next(10000) - 5000).ToShortDateString());

            case CsvColumnType.DateAndTime:
                return(DateTime.Now.AddSeconds(-1 * r.Next(60 * 60 * 24 * 365 * 4)).ToString());

            case CsvColumnType.Decimal:
                return((r.NextDouble() * 1000).ToString(CultureInfo.InvariantCulture));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }