You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When instantiating a new instance of test data, I pass the gender to the FirstName and Lastname where it seems to be used successfully. The Prefix also accepts it, but gives an inconsistent description. For male, I might get Ms and Mrs, for example. See code snippets for example below.
LINQPad Example or Reproduction Steps
public class FakePerson
{
public Gender Gender { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string MiddleName { get; set; }
public string FullName { get; set; }
public string Prefix { get; set; }
public string StreetAddress { get; set; }
public string City { get; set; }
public DateTime DateOfBirth { get; set; }
public bool SupportsGenderPrefixes { get; set; }
}
// get fake patient info:
var personFaker = new Faker<FakePerson>()
.RuleFor(p => p.Gender, f => f.PickRandom<Gender>())
.RuleFor(p => p.FirstName, (f, p) => f.Name.FirstName(p.Gender))
.RuleFor(p => p.LastName, (f, p) => f.Name.LastName(p.Gender))
.RuleFor(p => p.MiddleName, (f, p) => f.Name.FirstName(p.Gender))
.RuleFor(p => p.Prefix, (f, p) => f.Name.Prefix(p.Gender))
.RuleFor(p => p.StreetAddress, (f, p) => f.Address.StreetAddress())
.RuleFor(p => p.City, (f, p) => f.Address.City())
.RuleFor(p => p.DateOfBirth, (f, p) => f.Person.DateOfBirth)
.RuleFor(p => p.SupportsGenderPrefixes, (f, p) => f.Name.SupportsGenderPrefixes)
.RuleFor(p => p.FullName, (f, p)
=> p.FirstName + " " + p.LastName);
var person = personFaker.Generate();
Expected Behavior
Prefix should work like the first and last name and return a gendered version.
Actual Behavior
A random prefix is returned, independent of the passed gender.
Known Workarounds
Implemented my own method to map to something sensible to call from the rules:
///
/// The package is broken, doing this myself.
///
///
///
static string GetGenderPrefix(Gender gender)
{
return gender switch
{
Gender.Male => "Mr.",
Gender.Female => "Ms.", // or "Mrs." if you need to specify further
_ => "Mx." // Option for non-binary or unspecified
};
}
Could you help with a pull-request?
Yes
The text was updated successfully, but these errors were encountered:
Bogus NuGet Package
35.6.1
.NET Version
.net 8
Visual Studio Version
17.11.3
What operating system are you using?
Windows
What locale are you using with Bogus?
default
Problem Description
When instantiating a new instance of test data, I pass the gender to the FirstName and Lastname where it seems to be used successfully. The Prefix also accepts it, but gives an inconsistent description. For male, I might get Ms and Mrs, for example. See code snippets for example below.
LINQPad Example or Reproduction Steps
Expected Behavior
Prefix should work like the first and last name and return a gendered version.
Actual Behavior
A random prefix is returned, independent of the passed gender.
Known Workarounds
Implemented my own method to map to something sensible to call from the rules:
///
/// The package is broken, doing this myself.
///
///
///
static string GetGenderPrefix(Gender gender)
{
return gender switch
{
Gender.Male => "Mr.",
Gender.Female => "Ms.", // or "Mrs." if you need to specify further
_ => "Mx." // Option for non-binary or unspecified
};
}
Could you help with a pull-request?
Yes
The text was updated successfully, but these errors were encountered: