-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomUtilsU.pas
460 lines (413 loc) · 19.4 KB
/
RandomUtilsU.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
// *************************************************************************** }
//
// Delphi Fake Data Utils
//
// Copyright (c) 2010-2024 Daniele Teti and the DMVCFramework Team
//
// https://github.com/danieleteti/delphi_fake_data_utils
//
// ***************************************************************************
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ***************************************************************************
{$DEFINE GENERATE_DATASETS}
unit RandomUtilsU;
interface
{$IF Defined(GENERATE_DATASETS)}
uses
Data.DB, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf,
FireDAC.DApt.Intf, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
System.Generics.Collections;
{$ENDIF}
const
FirstNames: array [0 .. 29] of string = (
'Daniele',
'Debora',
'Mattia',
'Jack',
'James',
'William',
'Joseph',
'David',
'Charles',
'Thomas',
'Ethan',
'Liam',
'Noah',
'Logan',
'Lucas',
'Mason',
'Benjamin',
'Alexander',
'Elijah',
'Jordan',
'Alexander',
'Jamie',
'Tyler',
'Caleb',
'Kieran',
'Ryan',
'Colton',
'Jaxon',
'Gavin',
'Ryder'
);
LastNames: array [0 .. 13] of string = (
'Smith',
'Johnson',
'Williams',
'Brown',
'Black',
'Red',
'Green',
'Willis',
'Jones',
'Miller',
'Davis',
'Wilson',
'Martinez',
'Anderson'
);
Countries: array [0 .. 24] of string = (
'italy',
'new york',
'illinois',
'arizona',
'nevada',
'uk',
'france',
'georgia',
'spain',
'portugal',
'germany',
'norway',
'california',
'usa',
'japan',
'australia',
'singapore',
'hong kong',
'taiwan',
'south africa',
'canada',
'switzerland',
'sweden',
'netherlands',
'belgium'
);
LOREM_IPSUM =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' +
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' +
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.' +
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
WORDS: array [0 .. 1000] of string = ('bite', 'mate', 'quill', 'back', 'church', 'pear', 'knit', 'bent', 'wrench', 'crack', 'heavenly',
'deceive', 'maddening', 'plain', 'writer', 'rapid', 'acidic', 'decide', 'hat', 'paint', 'cow', 'dysfunctional', 'pet', 'giraffe',
'connection', 'sour', 'voracious', 'cloudy', 'wry', 'curve', 'agree', 'eggnog', 'flaky', 'painstaking', 'warm', 'silk', 'icy',
'hellish', 'toy', 'milky', 'skirt', 'test', 'daffy', 'questionable', 'gamy', 'aware', 'berry', 'throne', 'oven', 'subtract', 'cool',
'care', 'charge', 'smash', 'curve', 'comfortable', 'narrow', 'merciful', 'material', 'fear', 'exercise', 'skinny', 'fire',
'rainstorm', 'tail', 'nondescript', 'calculating', 'pack', 'steel', 'marvelous', 'baseball', 'furtive', 'stitch', 'abiding', 'empty',
'bushes', 'painful', 'tense', 'verse', 'unwritten', 'reproduce', 'receptive', 'bottle', 'silky', 'alleged', 'stingy', 'irritate',
'expand', 'cap', 'unsuitable', 'gigantic', 'exist', 'damp', 'scrub', 'disgusted', 'sun', 'ink', 'detailed', 'defeated', 'economic',
'chunky', 'stop', 'overflow', 'numerous', 'joyous', 'wipe', 'drink', 'error', 'branch', 'male', 'proud', 'soggy', 'ship', 'excite',
'industry', 'wistful', 'man', 'vacation', 'doctor', 'naughty', 'plane', 'ignore', 'open', 'act', 'earthquake', 'inconclusive',
'reflect', 'force', 'funny', 'wonder', 'magenta', 'near', 'dam', 'windy', 'maid', 'wacky', 'release', 'birthday', 'statement',
'psychotic', 'quicksand', 'things', 'planes', 'boundary', 'nod', 'touch', 'argue', 'sin', 'train', 'adhoc', 'needle', 'regret',
'stroke', 'strengthen', 'bruise', 'mine', 'rod', 'tax', 'twig', 'advise', 'stamp', 'rhyme', 'obnoxious', 'few', 'inform', 'fixed',
'mailbox', 'bells', 'grade', 'machine', 'yarn', 'lighten', 'tub', 'guiltless', 'hot', 'misty', 'van', 'flap', 'nosy', 'neighborly',
'crime', 'nifty', 'uninterested', 'noisy', 'oafish', 'squeal', 'page', 'wet', 'embarrassed', 'long-term', 'closed', 'language',
'argument', 'elite', 'ban', 'trip', 'tour', 'wine', 'profit', 'envious', 'love', 'back', 'bite-sized', 'magical', 'snatch', 'elated',
'sniff', 'far', 'shy', 'deeply', 'zoom', 'invent', 'downtown', 'heartbreaking', 'angry', 'can', 'bucket', 'important', 'fetch',
'shoe', 'self', 'x-ray', 'abhorrent', 'lumpy', 'fertile', 'nest', 'pick', 'history', 'offbeat', 'interrupt', 'yell', 'grain',
'scintillating', 'alluring', 'wren', 'form', 'attack', 'foregoing', 'suspect', 'daughter', 'moldy', 'signal', 'placid', 'quirky',
'itchy', 'butter', 'ordinary', 'imaginary', 'list', 'known', 'servant', 'slow', 'apparel', 'meeting', 'lovely', 'bat', 'insurance',
'waste', 'aromatic', 'foot', 'breakable', 'theory', 'stiff', 'cream', 'train', 'ground', 'fuel', 'wary', 'store', 'wonderful', 'corn',
'zippy', 'dashing', 'risk', 'prose', 'try', 'green', 'bead', 'recess', 'chop', 'stain', 'faded', 'heat', 'camera', 'panicky',
'depressed', 'wooden', 'clumsy', 'gullible', 'railway', 'guide', 'current', 'giants', 'enter', 'talented', 'bustling', 'square',
'jewel', 'bee', 'jelly', 'utopian', 'heal', 'anger', 'balance', 'tick', 'turn', 'unique', 'lively', 'wrist', 'fade', 'tender',
'outgoing', 'own', 'sigh', 'jobless', 'boiling', 'parallel', 'vest', 'leather', 'spark', 'suck', 'knot', 'circle', 'square', 'supply',
'tank', 'fax', 'spotless', 'habitual', 'feeling', 'watch', 'cattle', 'end', 'true', 'zonked', 'poison', 'man', 'pedal', 'boorish',
'moaning', 'mindless', 'bone', 'spot', 'chubby', 'numberless', 'eye', 'bright', 'sweet', 'fanatical', 'oranges', 'calm', 'squash',
'tooth', 'petite', 'design', 'one', 'bump', 'aberrant', 'mine', 'fit', 'rub', 'optimal', 'ugly', 'lyrical', 'borrow', 'queue',
'alert', 'normal', 'wrathful', 'truculent', 'level', 'hollow', 'disillusioned', 'kick', 'weather', 'mighty', 'upbeat', 'troubled',
'snotty', 'many', 'warn', 'thank', 'trains', 'plan', 'choke', 'activity', 'attend', 'walk', 'thought', 'gabby', 'actor', 'prickly',
'smell', 'dangerous', 'observation', 'action', 'steady', 'hypnotic', 'second-hand', 'zip', 'mundane', 'sand', 'sneaky', 'harm',
'pancake', 'guarantee', 'empty', 'bulb', 'burn', 'reject', 'decorate', 'obese', 'crowd', 'clap', 'flat', 'available', 'hop', 'untidy',
'wreck', 'fasten', 'waves', 'dinosaurs', 'dreary', 'fearful', 'answer', 'parched', 'tight', 'animated', 'desk', 'jaded', 'wax',
'silver', 'scream', 'puzzling', 'unbiased', 'unite', 'branch', 'quack', 'writing', 'tease', 'mint', 'full', 'plate', 'gusty', 'bear',
'bell', 'sparkling', 'absurd', 'past', 'earsplitting', 'seemly', 'unadvised', 'paper', 'battle', 'friend', 'control', 'rich',
'regret', 'used', 'scattered', 'redundant', 'slave', 'languid', 'didactic', 'fairies', 'sofa', 'spiteful', 'reply', 'division',
'engine', 'suppose', 'homeless', 'pinch', 'ray', 'channel', 'repeat', 'smoke', 'concentrate', 'handy', 'committee', 'songs', 'madly',
'itch', 'hands', 'clean', 'addition', 'majestic', 'careful', 'fallacious', 'guarded', 'last', 'time', 'tumble', 'plastic', 'force',
'guess', 'grape', 'loving', 'hand', 'remain', 'vigorous', 'wash', 'cars', 'same', 'provide', 'shelf', 'yam', 'onerous', 'claim',
'tramp', 'glistening', 'innocent', 'lock', 'close', 'absorbing', 'daily', 'amuck', 'manage', 'energetic', 'absent', 'fantastic',
'flippant', 'unnatural', 'amount', 'luxuriant', 'clover', 'alert', 'wheel', 'cellar', 'agonizing', 'card', 'memorise', 'meal',
'suspend', 'concerned', 'uneven', 'deranged', 'spiritual', 'arch', 'dare', 'hammer', 'tug', 'jump', 'vase', 'plant', 'color', 'worm',
'grab', 'frame', 'taste', 'incandescent', 'little', 'rule', 'confused', 'roomy', 'gorgeous', 'heat', 'whole', 'cracker', 'water',
'flimsy', 'high-pitched', 'grandfather', 'spooky', 'natural', 'grease', 'noiseless', 'superficial', 'gaze', 'finger', 'afford',
'racial', 'tiresome', 'tremendous', 'zealous', 'slip', 'position', 'mountainous', 'shelter', 'calculator', 'tacky', 'whip',
'mountain', 'clear', 'thin', 'smell', 'ants', 'yellow', 'cross', 'employ', 'trouble', 'dazzling', 'enchanting', 'groovy', 'measure',
'disapprove', 'elastic', 'sparkle', 'cub', 'foolish', 'discussion', 'stormy', 'pies', 'absorbed', 'trashy', 'mammoth', 'low',
'subdued', 'badge', 'letter', 'previous', 'challenge', 'tart', 'cute', 'suit', 'condition', 'pricey', 'rule', 'wrong', 'bomb', 'wiry',
'swim', 'crack', 'disgusting', 'gather', 'half', 'sturdy', 'probable', 'stream', 'trick', 'silly', 'sulky', 'nail', 'rotten', 'stir',
'sneeze', 'even', 'adamant', 'cluttered', 'object', 'battle', 'petite', 'wait', 'instinctive', 'donkey', 'squeamish', 'rainy',
'craven', 'acceptable', 'husky', 'pollution', 'judicious', 'distribution', 'neck', 'left', 'collect', 'thankful', 'describe',
'complex', 'transport', 'horses', 'hope', 'chemical', 'dress', 'idea', 'extend', 'laugh', 'event', 'route', 'hose', 'abundant',
'insect', 'spectacular', 'whistle', 'home', 'vast', 'massive', 'grey', 'sail', 'lavish', 'word', 'coach', 'repair', 'squeak',
'curious', 'beam', 'middle', 'obscene', 'efficacious', 'supreme', 'torpid', 'jazzy', 'linen', 'cause', 'synonymous', 'book', 'brave',
'staking', 'weak', 'show', 'birds', 'barbarous', 'hilarious', 'injure', 'walk', 'screeching', 'frequent', 'wide', 'kiss', 'lonely',
'quarrelsome', 'arm', 'flowers', 'surround', 'level', 'enjoy', 'calculate', 'reach', 'brother', 'grandiose', 'clammy', 'thunder',
'pen', 'rake', 'whirl', 'sharp', 'fence', 'scissors', 'polish', 'recondite', 'brief', 'pig', 'ten', 'spell', 'coal', 'sidewalk',
'straight', 'melted', 'ring', 'deadpan', 'nine', 'wound', 'use', 'switch', 'watch', 'meat', 'governor', 'lively', 'neat', 'dapper',
'gate', 'rose', 'wealthy', 'psychedelic', 'slap', 'note', 'request', 'match', 'abashed', 'snail', 'tray', 'pump', 'disappear',
'vegetable', 'wool', 'abstracted', 'impulse', 'fork', 'brake', 'shiny', 'team', 'coherent', 'dust', 'relieved', 'long', 'broad',
'shop', 'innate', 'milk', 'mother', 'screw', 'cushion', 'listen', 'spot', 'willing', 'legs', 'clever', 'obsolete', 'coil', 'smoke',
'call', 'men', 'purpose', 'bumpy', 'receipt', 'soothe', 'thinkable', 'launch', 'kittens', 'oceanic', 'dolls', 'jagged', 'fine',
'start', 'muddled', 'want', 'develop', 'skillful', 'real', 'sisters', 'cooperative', 'retire', 'scarecrow', 'caring', 'chance',
'search', 'visitor', 'stem', 'rabid', 'seed', 'endurable', 'cloistered', 'knife', 'cast', 'trouble', 'cold', 'brainy', 'admit',
'base', 'multiply', 'escape', 'bike', 'frighten', 'large', 'pull', 'observant', 'stereotyped', 'dirty', 'tin', 'vague', 'celery',
'hungry', 'best', 'difficult', 'burly', 'horse', 'flawless', 'fresh', 'inquisitive', 'illegal', 'omniscient', 'simplistic', 'selfish',
'clean', 'hospital', 'encouraging', 'incompetent', 'right', 'learn', 'relation', 'spoil', 'amused', 'ruthless', 'squalid',
'aftermath', 'increase', 'greasy', 'futuristic', 'shut', 'friendly', 'steep', 'range', 'faint', 'jail', 'wide-eyed', 'uptight',
'erratic', 'eyes', 'cure', 'overwrought', 'muddle', 'bedroom', 'scale', 'rub', 'conscious', 'snake', 'box', 'command', 'slippery',
'handsome', 'spy', 'tongue', 'unbecoming', 'magnificent', 'gold', 'resolute', 'face', 'childlike', 'approval', 'meaty', 'frog',
'abrasive', 'rat', 'peel', 'office', 'panoramic', 'explode', 'selective', 'ahead', 'thaw', 'mean', 'odd', 'hate', 'window', 'somber',
'guard', 'riddle', 'judge', 'flock', 'black', 'amusement', 'bikes', 'milk', 'sock', 'historical', 'tawdry', 'bare', 'mitten', 'harsh',
'street', 'unequal', 'five', 'zinc', 'faulty', 'messy', 'thoughtful', 'spicy', 'oval', 'telephone', 'decisive', 'teeny', 'fix',
'outstanding', 'excuse', 'abject', 'print', 'receive', 'jump', 'knock', 'ubiquitous', 'anxious', 'fill', 'shrug', 'ossified',
'penitent', 'dry', 'abaft', 'uncle', 'voiceless', 'spray', 'town', 'aspiring', 'testy', 'bed', 'likeable', 'breezy', 'jumpy', 'talk',
'powerful', 'various', 'crawl', 'lacking', 'lethal', 'baby', 'sore', 'mourn', 'behave', 'pass', 'mark', 'summer', 'cause',
'destruction', 'stale', 'basin', 'embarrass', 'rob', 'income', 'overjoyed', 'aback', 'spark', 'air', 'worthless', 'hospitable',
'dynamic', 'push', 'nervous', 'dark', 'chin', 'shock', 'frame', 'dojo');
type
TPerson = class
private
FID: Integer;
FName: String;
FEMail: String;
FSurname: String;
FDOB: TDate;
public
property ID: Integer read FID write FID;
property Name: String read FName write FName;
property Surname: String read FSurname write FSurname;
property DOB: TDate read FDOB write FDOB;
property EMail: String read FEMail write FEMail;
constructor Create(const ID: Integer; const Name, Surname: String; const DOB: TDate; const EMail: String);
end;
function GetRndFirstName: String;
function GetRndLastName: String;
function GetRndFullName: String;
function GetRndCountry: String;
function GetRndEMailAddress: String;
function GetRndFrom(const ArrayOfString: TArray<String>): String; overload;
function GetRndFrom(const ArrayOfInteger: TArray<Integer>): Integer; overload;
function GetRndDate(const InitialYear: Word = 1980; YearsSpan: Word = 40): TDate; overload;
function GetRndDate(const InitialDate: TDate; const DaysSpan: Word = 365): TDate; overload;
function GetRndInteger(const aFrom: Integer = 0; aTo: Integer = 1000): Integer;
function GetRndFloat(const aFrom: Extended = 0; aTo: Extended = 1000): Extended;
function GetRndWord: String;
function GetRndPhrase(const aFrom: Integer = 0; aTo: Integer = 1000): String;
function GetPeopleObjectList(const Count: Integer): TObjectList<TPerson>;
{$IF Defined(GENERATE_DATASETS)}
function GetPeople(const Count: Integer = 20): TDataSet;
function GetUsers(const Count: Integer = 10): TDataSet;
function GetPosts(const Count: Integer = 10): TDataSet;
{$ENDIF}
implementation
uses
System.SysUtils, System.DateUtils, System.Math;
const
OneDay = OneHour * 24;
function GetRndDate(const InitialDate: TDate; const DaysSpan: Word = 365): TDate; overload;
begin
Result := InitialDate + (OneDay * Random(DaysSpan));
end;
function GetRndDate(const InitialYear: Word; YearsSpan: Word): TDate;
begin
Result := EncodeDate(InitialYear + Random(YearsSpan),1,1) + (OneDay * Random(365));
end;
function GetRndEMailAddress: String;
begin
Result := GetRndFirstName.Substring(0, RandomRange(1,3)) + '.' +
GetRndLastName + '@' + GetRndCountry + GetRndInteger(1,3).ToString + '.com';
Result := Result.Replace(' ', '_', [rfReplaceAll]);
end;
function GetRndFrom(const ArrayOfString: TArray<String>): String;
begin
Result := ArrayOfString[Random(Length(ArrayOfString))];
end;
function GetRndFrom(const ArrayOfInteger: TArray<Integer>): Integer;
begin
Result := ArrayOfInteger[Random(Length(ArrayOfInteger))];
end;
function GetRndCountry: String;
begin
Result := Countries[Random(High(Countries)+1)];
end;
function GetRndFirstName: String;
begin
Result := FirstNames[Random(High(FirstNames)+1)];
end;
function GetRndFullName: String;
begin
Result := GetRndFirstName + ' ' + GetRndLastName;
end;
function GetRndLastName: String;
begin
Result := LastNames[Random(High(LastNames)+1)];
end;
function GetRndWord: String;
begin
Result := WORDS[RandomRange(0, Length(WORDS))];
end;
function GetRndPhrase(const aFrom: Integer = 0; aTo: Integer = 1000): String;
var
WordCount: Integer;
I: Integer;
begin
Result := '';
WordCount := RandomRange(aFrom, aTo);
for I := 1 to WordCount do
begin
Result := Result + GetRndWord + ' ';
end;
Result := Result.Trim;
Result := UpCase(Result.Chars[0]) + Result.Substring(1) + '.';
end;
function GetRndFloat(const aFrom: Extended = 0; aTo: Extended = 1000): Extended;
begin
if aFrom >= aTo then
begin
raise Exception.Create('FROM cannot be greater nor equal to TO');
end;
Result := afrom + (Random(Trunc(aTo * 10000)) / 10000);
end;
function GetRndInteger(const aFrom: Integer; aTo: Integer): Integer;
begin
if aFrom >= aTo then
begin
raise Exception.Create('FROM cannot be greater nor equal to TO');
end;
Result := RandomRange(aFrom, aTo);
end;
{$IF Defined(GENERATE_DATASETS)}
function GetPeople(const Count: Integer): TDataSet;
var
lMT: TFDMemTable;
I: Integer;
begin
lMT := TFDMemTable.Create(nil);
try
lMT.FieldDefs.Clear;
lMT.FieldDefs.Add('code', ftInteger);
lMT.FieldDefs.Add('first_name', ftString, 20);
lMT.FieldDefs.Add('last_name', ftString, 20);
lMT.FieldDefs.Add('country', ftString, 20);
lMT.FieldDefs.Add('dob', ftDate);
lMT.Active := True;
for I := 1 to Count do
begin
lMT.AppendRecord([I, GetRndFirstName, GetRndLastName, GetRndCountry, GetRndDate]);
end;
lMT.First;
Result := lMT;
except
lMT.Free;
raise;
end;
end;
function GetUsers(const Count: Integer): TDataSet;
var
lMT: TFDMemTable;
I: Integer;
begin
lMT := TFDMemTable.Create(nil);
try
lMT.FieldDefs.Clear;
lMT.FieldDefs.Add('first_name', ftString, 100);
lMT.FieldDefs.Add('last_name', ftString, 100);
lMT.FieldDefs.Add('email', ftString, 100);
lMT.Active := True;
for I := 1 to Count do
begin
lMT.AppendRecord([GetRndFirstName, GetRndLastName, GetRndEMailAddress]);
end;
lMT.First;
Result := lMT;
except
lMT.Free;
raise;
end;
end;
function GetPosts(const Count: Integer): TDataSet;
var
lMT: TFDMemTable;
I: Integer;
begin
lMT := TFDMemTable.Create(nil);
try
lMT.FieldDefs.Clear;
lMT.FieldDefs.Add('title', ftString, 100);
lMT.FieldDefs.Add('abstract', ftString, 400);
lMT.FieldDefs.Add('word_count', ftInteger);
lMT.FieldDefs.Add('comments', ftInteger);
lMT.FieldDefs.Add('post_date', ftDate);
lMT.Active := True;
for I := 1 to Count do
begin
lMT.AppendRecord([
GetRndPhrase(3, 8),
GetRndPhrase(30, 50),
GetRndInteger(20, 5000),
GetRndInteger(0,20),
GetRndDate(2020, 4)
]);
end;
lMT.First;
Result := lMT;
except
lMT.Free;
raise;
end;
end;
{$ENDIF}
{ TPerson }
constructor TPerson.Create(const ID: Integer; const Name, Surname: String; const DOB: TDate; const EMail: String);
begin
inherited Create;
FID := ID;
FName := Name;
FSurname := Surname;
FDOB := DOB;
FEMail := EMail;
end;
function GetPeopleObjectList(const Count: Integer): TObjectList<TPerson>;
var
I: Integer;
begin
Result := TObjectList<TPerson>.Create;
try
for I := 1 to Count do
begin
Result.Add(TPerson.Create(I, GetRndFirstName, GetRndLastName, GetRndDate, GetRndEMailAddress));
end;
except
Result.Free;
raise;
end;
end;
initialization
Randomize;
end.