forked from bchavez/Bogus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Locale data parity with faker.js at https://github.com/Marak/faker.js…
- Loading branch information
Showing
70 changed files
with
19,887 additions
and
1,787 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Bogus.DataSets; | ||
using FluentAssertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Bogus.Tests.DataSetTests | ||
{ | ||
public class MusicTests : SeededTest | ||
{ | ||
private readonly ITestOutputHelper console; | ||
private Music music; | ||
|
||
public MusicTests(ITestOutputHelper console) | ||
{ | ||
this.console = console; | ||
this.music = new Music(); | ||
} | ||
|
||
[Fact] | ||
public void can_generate_genre() | ||
{ | ||
this.music.Genre().Should().Be("Hip Hop"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using System; | ||
using Xunit; | ||
using Bogus.Extensions; | ||
using Xunit.Abstractions; | ||
|
||
namespace Bogus.Tests.GitHubIssues | ||
{ | ||
public class Issue321 : SeededTest | ||
{ | ||
private readonly ITestOutputHelper console; | ||
|
||
public Issue321(ITestOutputHelper console) | ||
{ | ||
this.console = console; | ||
} | ||
|
||
[Fact] | ||
public void reuse_data_from_custom_instantiator() | ||
{ | ||
var unions = new[] | ||
{ | ||
new Union("Married"), | ||
new Union("Single"), | ||
new Union("Divorced"), | ||
}; | ||
|
||
var memberFaker = new Faker<Member>() | ||
.CustomInstantiator(f => | ||
{ | ||
//Store intermediate state here. | ||
var email = f.Internet.ExampleEmail(); | ||
var selectedUnion = f.PickRandom(unions); | ||
|
||
return new Member( | ||
f.Random.Guid().ToString("N"), | ||
f.Name.FullName(), | ||
f.Date.Between(new DateTime(1950, 3, 9), new DateTime(2010, 4, 2)), | ||
f.Address.FullAddress(), | ||
f.Phone.PhoneNumber(), | ||
email, | ||
CreateAppUser(email).Id, | ||
selectedUnion, | ||
selectedUnion.Id, | ||
f.Random.ReplaceNumbers("######"), | ||
f.Rant.Random.Words(5) | ||
); | ||
}); | ||
|
||
var testMembers = memberFaker.GenerateBetween(4, 10); | ||
console.Dump(testMembers); | ||
} | ||
|
||
private AppUser CreateAppUser(string email) | ||
{ | ||
return new AppUser(email); | ||
} | ||
|
||
public class AppUser | ||
{ | ||
public AppUser(string email) | ||
{ | ||
this.Email = email; | ||
this.Id = $"appuser_id:{this.Email.ToLower()}"; | ||
} | ||
|
||
public string Email { get; set; } | ||
|
||
public string Id { get; set; } | ||
} | ||
|
||
public class Union | ||
{ | ||
public Union(string description) | ||
{ | ||
this.Description = description; | ||
this.Id = $"union_id:{this.Description.ToLower()}"; | ||
} | ||
|
||
public string Description { get; set; } | ||
|
||
public string Id { get; set; } | ||
} | ||
|
||
public class Member | ||
{ | ||
public string Id { get; } | ||
public string Name { get; } | ||
public DateTime Dob { get; } | ||
public string Address { get; } | ||
public string Phone { get; } | ||
public string Email { get; } | ||
public string AppUserId { get; } | ||
public Union Union { get; } | ||
public string UnionId { get; } | ||
public string Code { get; } | ||
public string Description { get; } | ||
|
||
public Member( | ||
string id, | ||
string name, | ||
DateTime dob, | ||
string address, | ||
string phone, | ||
string email, | ||
string appUserId, | ||
Union union, | ||
string unionId, | ||
string code, | ||
string description) | ||
{ | ||
this.Id = id; | ||
this.Name = name; | ||
this.Dob = dob; | ||
this.Address = address; | ||
this.Phone = phone; | ||
this.Email = email; | ||
this.AppUserId = appUserId; | ||
this.Union = union; | ||
this.UnionId = unionId; | ||
this.Code = code; | ||
this.Description = description; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Bogus.DataSets | ||
{ | ||
public class Music : DataSet | ||
{ | ||
/// <summary> | ||
/// Get a music genre | ||
/// </summary> | ||
public string Genre() | ||
{ | ||
return GetRandomArrayItem("genre"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"title": "South Africa (Afrikaans)", | ||
"title": "Afrikaans", | ||
"address": { | ||
"default_country": [ | ||
"South Africa" | ||
|
Binary file not shown.
Oops, something went wrong.