Dump Data - Tạo data giả (edit)
1) Tạo data giả trong javascript sử dụng faker.js
function GetRandomStudent() { return { Id : faker.random.number(100), Name : faker.name.findName(), Username : faker.internet.userName(), Password: faker.internet.password(), Email : faker.internet.email(), Age : faker.random.number(100), Address: faker.address.streetAddress(), Birthdate: faker.date.past() }; } var students = []; for (var i = 0; i < 100; i++) { students.push(GetRandomStudent()); }
2) Tạo data giả trong C# sử dụng Faker.NET
Install-Package Faker.Net
public class Student { public int Id { get; set; } public string Name { get; set; } public string Address { get; set; } public string Username { get; set; } public int Age { get; set; } public string Email { get; set; } public static Student GetRandomStudent() { var name = Faker.Name.FullName(NameFormats.Standard); return new Student { Id = Faker.RandomNumber.Next(100), Name = name, Username = Faker.Internet.UserName(name), Email = Faker.Internet.Email(name), Age = Faker.RandomNumber.Next(50), Address = Faker.Address.StreetAddress(), }; } } //Tạo 100 random student var students = new List(); for (int i = 0; i < 100; i++) students.Add(Student.GetRandomStudent());
3) Tạo data giả dưới database sử dụng Mockaroo
http://www.michael-whelan.net/creating-test-data-with-mockaroo/
https://github.com/manhnguyenv/MockarooSandbox