Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.javafaker; | ||
|
||
public class Gender { | ||
|
||
private final Faker faker; | ||
|
||
protected Gender(Faker faker) { this.faker = faker; } | ||
|
||
/** | ||
* <p> | ||
* A gender which maybe special. Examples: | ||
* <ul> | ||
* <li>Non-binary</li> | ||
* <li>Genderfluid</li> | ||
* </ul> | ||
* </p> | ||
* @return a random gender. | ||
*/ | ||
public String types() { return faker.fakeValuesService().resolve("gender.types", this, faker); } | ||
|
||
/** | ||
* <p> | ||
* A gender which if male or female. Examples: | ||
* <ul> | ||
* <li>male</li> | ||
* <li>female</li> | ||
* </ul> | ||
* </p> | ||
* @return a random binary gender. | ||
*/ | ||
public String binarytypes() { | ||
return faker.fakeValuesService().resolve("gender.binary_types", this, faker); | ||
} | ||
} |
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,15 @@ | ||
package com.github.javafaker; | ||
import org.junit.Test; | ||
|
||
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class GenderTest extends AbstractFakerTest { | ||
|
||
@Test | ||
public void testType() { assertThat(faker.gender().types(), matchesRegularExpression("([\\w-]+ ?)+")); } | ||
|
||
@Test | ||
public void testBinarytypes() { assertThat(faker.gender().binarytypes(), matchesRegularExpression("([\\w-]+ ?)+")); } | ||
|
||
} |