Fake names

Needed to generate fake names and emails today for a stub API I’m developing. Found a github gist that did the trick. Very easy. Just had to install the faker gem first:

$ sudo gem install faker

The example generates to CSV but I needed from object instances for C# so changed the code as such:

require 'faker'
require 'securerandom'

File.open("output.txt", "wb") do |file|
  i=0
  until i == 500
    uuid = SecureRandom.uuid
    fake = "new SearchUserResult("" + Faker::Name.name + "", "" +
        Faker::Internet.email + "", UserType.Person, "" + uuid + ""),n"
    file << fake
    i=i+1
  end
end