delphi_fake_data_utils
Simple unit to generate fake data for demo, samples, testing etc.
- Active · last change 7-23-2025
- ★ 17 on GitHub
README
Delphi Fake Data Utils
Generate realistic fake data for testing, development, and prototyping in Delphi applications
A comprehensive library for generating fake but realistic data in Delphi applications. Perfect for unit testing, database seeding, API testing, demos, and any scenario where you need convincing sample data.
🤔 What is Fake Data and Why Do You Need It?
Fake data (also known as synthetic data or mock data) is artificially generated information that mimics real-world data patterns without containing actual sensitive information. It's an essential tool in modern software development.
Why Use Fake Data?
- 🔒 Privacy & Security: Test with realistic data without exposing real user information
- 🚀 Development Speed: Quickly populate databases and test scenarios without waiting for real data
- 🧪 Comprehensive Testing: Create edge cases and specific scenarios that might not exist in production
- 📊 Demos & Prototypes: Impress clients with realistic-looking applications
- ⚡ Load Testing: Generate thousands of records for performance testing
- 🔄 Reproducible Tests: Create consistent test scenarios across different environments
When NOT to Use Real Data
- GDPR Compliance: Avoid privacy violations by using fake data for development
- Database Seeding: Don't copy production data to development environments
- Unit Testing: Tests should be predictable and not depend on external data
- Presentations: Avoid showing real customer information in demos
🎯 Perfect Use Cases
| Scenario | How Delphi Fake Data Utils Helps |
|---|---|
| Unit Testing | Generate predictable test data for your business logic |
| Database Seeding | Populate development databases with realistic records |
| API Testing | Create varied payloads for REST/GraphQL endpoint testing |
| Load Testing | Generate thousands of records to test performance |
| DelphiMVCFramework | Perfect companion for testing web APIs and services |
| UI Prototyping | Fill grids, lists, and forms with convincing sample data |
| Client Demos | Show realistic applications without real customer data |
| Data Migration Testing | Test import/export processes with controlled datasets |
🚀 Quick Start
Installation
- Download the repository
- Add
RandomUtilsU.pasto your project - Add
RandomUtilsUto your uses clause
uses
RandomUtilsU;Your First Fake Data
program QuickExample;
uses
System.SysUtils, RandomUtilsU;
begin
// Generate a random person
Writeln('Name: ' + GetRndFullName);
Writeln('Email: ' + GetRndEMailAddress);
Writeln('Country: ' + GetRndCountry);
Writeln('Salary: $' + FloatToStr(GetRndInteger(30000, 120000)));
ReadLn;
end.Output:
Name: Marco Ferrari
Email: marco.ferrari@libero.it
Country: italy
Salary: $75000📚 Core Features
🌍 Internationalization Support
Generate location-specific data for different countries:
// Italian data
WriteLn(GetRndFullName(lcIT)); // "Giuseppe Rossi"
WriteLn(GetRndEMailAddress(lcIT)); // "giuseppe.rossi@libero.it"
WriteLn(GetRndPhoneNumber(lcIT)); // "+39 345 678 9012"
WriteLn(GetRndAddress(lcIT)); // "Via Roma 123, 00100 Roma"
// US data
WriteLn(GetRndFullName(lcUS)); // "John Smith"
WriteLn(GetRndEMailAddress(lcUS)); // "john.smith@gmail.com"
WriteLn(GetRndPhoneNumber(lcUS)); // "+1 (555) 123-4567"
WriteLn(GetRndAddress(lcUS)); // "Main Street 456, 12345 New York"Supported Locales: lcIT (Italian), lcUS (US English), lcUK (UK English), lcDE (German), lcFR (French)
🏢 Business Data Generation
Create realistic business scenarios:
// Company data
Company := GetRndCompanyName; // "TechSolutions"
Industry := GetRndIndustry; // "Information Technology"
Website := GetRndURL; // "https://www.techpro123.com"
// Employee data
JobTitle := GetRndJobTitle; // "Software Developer"
Salary := GetRndSalary(25000, 150000); // Context-aware salary ranges
PhoneNumber := GetRndPhoneNumber(lcUS); // "+1 (555) 987-6543"🛍️ E-commerce & Product Data
Perfect for testing online stores and inventory systems:
// Product information
ProductName := GetRndProductName; // "UltraTech Pro"
Category := GetRndProductCategory; // "Electronics"
SKU := GetRndSKU; // "AB-1234-CD"
Price := GetRndPrice(9.99, 999.99); // 299.99
Color := GetRndColor; // "Blue"
ColorHex := GetRndColorHex; // "#0000FF"
Description := GetRndPhrase(10, 30); // "Innovative solution for modern..."💻 Technical Data
Generate networking and technical information:
// Network data
PublicIP := GetRndIPAddress(False); // "203.45.67.89"
LocalIP := GetRndIPAddress(True); // "192.168.1.100"
MacAddress := GetRndMacAddress; // "AA:BB:CC:DD:EE:FF"
URL := GetRndURL; // "https://www.example123.com"
// Secure URLs
SecureURL := GetRndURL('myapi.com', True); // "https://myapi.com"💳 Financial Data (Testing Only)
Generate fake financial data for payment testing:
// ⚠️ WARNING: These are FAKE numbers for testing only!
CreditCard := GetRndCreditCardNumber('VISA'); // "4123-4567-8901-2345"
IBAN := GetRndIBAN('IT'); // "IT85 X 1234 5678 123456789012"
BankAccount := GetRndBankAccount; // "1234-5678-9012-3456"
// Validate fake data
if IsValidFakeEmail('test@example.com') then
WriteLn('Email format is valid');🏗️ Advanced Usage
Complex Person Objects
var
Person: TPerson;
begin
Person := TPerson.Create;
try
Person.ID := 1;
Person.Name := GetRndFirstName(lcIT);
Person.Surname := GetRndLastName(lcIT);
Person.EMail := GetRndEMailAddress(Person.Name, Person.Surname, lcIT);
Person.JobTitle := GetRndJobTitle;
Person.Salary := GetRndSalary(30000, 120000);
Person.Address := GetRndAddress(lcIT);
Person.PhoneNumber := GetRndPhoneNumber(lcIT);
Person.DOB := GetRndDate(1970, 35); // Age between 35-70
// Use the person object...
ShowMessage(Format('%s %s works as %s', [
Person.Name, Person.Surname, Person.JobTitle
]));
finally
Person.Free;
end;
end;Dataset Generation
Generate complete datasets for testing:
{$IF Defined(GENERATE_DATASETS)}
var
PeopleDataSet: TDataSet;
begin
// Generate 100 Italian people
PeopleDataSet := GetPeople(100, lcIT);
try
// Use with database components, grids, etc.
DataSource1.DataSet := PeopleDataSet;
finally
PeopleDataSet.Free;
end;
end;
{$ENDIF}Available Datasets:
GetPeople(Count, Locale)- Complete person recordsGetCompanies(Count, Locale)- Company informationGetProducts(Count)- Product catalogGetEmployees(Count, Locale)- Employee recordsGetPosts(Count)- Blog posts/articles
Text Generation
Create realistic content:
// Different phrase lengths
ShortTitle := GetRndPhrase(3, 8); // "Innovative Tech Solutions."
Description := GetRndPhrase(15, 30); // "Advanced system for modern..."
LongContent := GetRndPhrase(50, 100); // Full paragraph
// Individual words
RandomWord := GetRndWord; // "innovative"🔧 DelphiMVCFramework Integration
Perfect companion for testing MVCFramework applications:
// In your MVCFramework controller tests
procedure TTestUserController.TestCreateUser;
var
UserData: TJSONObject;
Response: TMVCResponse;
begin
// Create realistic test data
UserData := TJSONObject.Create;
try
UserData.AddPair('name', GetRndFirstName(lcUS));
UserData.AddPair('surname', GetRndLastName(lcUS));
UserData.AddPair('email', GetRndEMailAddress(lcUS));
UserData.AddPair('phone', GetRndPhoneNumber(lcUS));
UserData.AddPair('salary', TJSONNumber.Create(GetRndSalary(40000, 120000)));
// Test your API endpoint
Response := PostJSON('/api/users', UserData);
Assert.AreEqual(201, Response.StatusCode);
finally
UserData.Free;
end;
end;📊 Performance & Statistics
The library is optimized for high performance:
var
StartTime: TDateTime;
I: Integer;
begin
StartTime := Now;
// Generate 10,000 names
for I := 1 to 10000 do
GetRndFullName(lcIT);
WriteLn(Format('Generated 10,000 names in %.3f seconds', [
(Now - StartTime) * 24 * 60 * 60
]));
// Typical output: ~0.05 seconds
end;🛡️ Data Validation
Built-in validators for generated data:
// Validate generated data
Email := GetRndEMailAddress;
if IsValidFakeEmail(Email) then
WriteLn('Email is properly formatted');
IBAN := GetRndIBAN('IT');
if IsValidFakeIBAN(IBAN) then
WriteLn('IBAN format is correct');
Phone := GetRndPhoneNumber(lcIT);
if IsValidFakePhoneNumber(Phone, lcIT) then
WriteLn('Phone number format is valid');📖 API Reference
Core Functions
| Function | Description | Example |
|---|---|---|
GetRndFirstName(Locale?) |
Random first name | "Marco" |
GetRndLastName(Locale?) |
Random last name | "Rossi" |
GetRndFullName(Locale?) |
Full name | "Marco Rossi" |
GetRndEMailAddress(...) |
Email address | "marco.rossi@gmail.com" |
GetRndPhoneNumber(Locale) |
Phone number | "+39 345 678 9012" |
GetRndAddress(Locale?) |
Full address | "Via Roma 123, 00100 Roma" |
GetRndDate(...) |
Random date | Various overloads |
GetRndInteger(Min, Max) |
Random integer | 42 |
GetRndFloat(Min, Max) |
Random float | 123.45 |
Business Functions
| Function | Description | Example |
|---|---|---|
GetRndCompanyName |
Company name | "TechSolutions" |
GetRndIndustry |
Industry type | "Information Technology" |
GetRndJobTitle |
Job title | "Software Developer" |
GetRndSalary(Min, Max) |
Salary amount | 75000 |
Product Functions
| Function | Description | Example |
|---|---|---|
GetRndProductName |
Product name | "UltraTech Pro" |
GetRndProductCategory |
Category | "Electronics" |
GetRndSKU |
SKU code | "AB-1234-CD" |
GetRndPrice(Min, Max) |
Price | 299.99 |
GetRndColor |
Color name | "Blue" |
GetRndColorHex |
Hex color | "#0000FF" |
Technical Functions
| Function | Description | Example |
|---|---|---|
GetRndIPAddress(Local?) |
IP address | "192.168.1.100" |
GetRndMacAddress |
MAC address | "AA:BB:CC:DD:EE:FF" |
GetRndURL(...) |
Website URL | "https://example.com" |
Financial Functions (Fake Only!)
| Function | Description | Example |
|---|---|---|
GetRndCreditCardNumber(Type) |
Credit card | "4123-4567-8901-2345" |
GetRndIBAN(Country) |
IBAN | "IT85 X 1234 5678..." |
GetRndBankAccount |
Bank account | "1234-5678-9012-3456" |
Validation Functions
| Function | Description |
|---|---|
IsValidFakeEmail(Email) |
Validate email format |
IsValidFakeIBAN(IBAN) |
Validate IBAN format |
IsValidFakeCreditCard(Card) |
Validate card format |
IsValidFakePhoneNumber(Phone, Locale) |
Validate phone format |
🏗️ Requirements
- Delphi XE2+ (tested up to Delphi 12)
- Windows (Win32/Win64)
- FireDAC (for dataset generation, optional)
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Development Setup
- Clone the repository
- Open in Delphi XE2 or newer
- Compile and run the sample projects
- Run tests to ensure everything works
Areas for Contribution
- Additional locales (Spanish, Portuguese, etc.)
- More business domains (healthcare, finance, etc.)
- Performance optimizations
- Additional validators
- Documentation improvements
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🙏 Acknowledgments
- Daniele Teti - Original creator and maintainer
- DMVCFramework Team - Ongoing support and development
- Contributors and users who provided feedback and improvements
📞 Support
- GitHub Issues: Report bugs or request features
- Website: [https://www.danieleteti.it](https://www.danieleteti.it)
- DelphiMVCFramework: [https://github.com/danieleteti/delphimvcframework](https://github.com/danieleteti/delphimvcframework)
⭐ Star this project if you find it useful! It helps others discover this tool.
📢 Share your use cases - we love to hear how you're using Delphi Fake Data Utils in your projects!

