BT

Use Faker.NET To Fake Your Data

by Roopesh Shenoy on Apr 03, 2012 |

Faker is an open source C# port of the Ruby Faker gem mainly used to easily generate fake (but presentable) data – names, addresses, phone numbers, etc. Handy, whether its for demonstration purposes or for creating test data.

How does it work? A look inside the code shows how – the solution contains resource files with possible good values for each of the attributes (for eg. First Name, Last Name, etc) and code randomly mixes and matches these to generate the data. The more the pre-fed values for each of these attributes, the more combinations are possible and hence richer the data. Depending on your specific needs, you might want to modify the resource files to reflect the data you need (for instance, names or addresses localized to a particular region). An article from Ollie Riches shows a quick usage of the library.

The utility is compatible with .NET Framework 4.0, Silverlight 3-5 and Windows Phone 7.0 and 7.1. It is available as a NuGet Package.

There is another GitHub project with the same name (Faker.NET) that seems to work in the same way except for a couple of things – the possible values are directly in the C# code (instead of resource files) and it has an additional class for Education (Degree, Major, School, etc).

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT