From 49485288372fb2b2d119a350b2780554033d7d72 Mon Sep 17 00:00:00 2001 From: bchavez Date: Sun, 20 Aug 2017 21:32:15 -0700 Subject: [PATCH] Fixes #88 - :lipstick: API aesthetics: Added `Name.FullName()` convenience method to generate a full name. --- HISTORY.md | 3 +++ Source/Bogus.Tests/DataSetTests/NameTests.cs | 6 ++++++ Source/Bogus/DataSets/Name.cs | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index f06784f9..077c87cc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +## v15.0.7 +* Issue #88 - API aesthetics: Added `Name.FullName()` convenience method to generate a full name. + ## v15.0.6 * PR #87: Added `.Rules()` method on `RuleSet`. Thanks @digitalcyote. diff --git a/Source/Bogus.Tests/DataSetTests/NameTests.cs b/Source/Bogus.Tests/DataSetTests/NameTests.cs index 653816bd..ad36a512 100644 --- a/Source/Bogus.Tests/DataSetTests/NameTests.cs +++ b/Source/Bogus.Tests/DataSetTests/NameTests.cs @@ -120,5 +120,11 @@ public void switch_locale_syntax() //switch to EN n["en"].LastName().Should().Be("Schultz"); } + + [Fact] + public void can_get_a_full_name() + { + name.FullName().Should().Be("Lee Brown"); + } } } \ No newline at end of file diff --git a/Source/Bogus/DataSets/Name.cs b/Source/Bogus/DataSets/Name.cs index 0ebb1b99..d9090006 100644 --- a/Source/Bogus/DataSets/Name.cs +++ b/Source/Bogus/DataSets/Name.cs @@ -75,6 +75,15 @@ public string LastName(Gender? gender = null) return GetRandomArrayItem("last_name"); } + /// + /// Get a full name, concatenation of calling FirstName and LastName. + /// + /// Gender of the name if supported by the locale. + public string FullName(Gender? gender = null) + { + return $"{FirstName(gender)} {LastName(gender)}"; + } + /// /// Gets a random prefix for a name ///