1- using NTestDataBuilder . DataSources . Person ;
1+ using System . Dynamic ;
2+ using NTestDataBuilder . DataSources . Generators ;
3+ using NTestDataBuilder . DataSources . Person ;
24
35namespace NTestDataBuilder . EquivalenceClasses . Person
46{
@@ -8,6 +10,7 @@ namespace NTestDataBuilder.EquivalenceClasses.Person
810 public static class NameEquivalenceClasses
911 {
1012 private static PersonEmailAddressSource _personEmailAddressSource ;
13+ private static PersonEmailAddressSource _personUniqueEmailAddressSource ;
1114 private static PersonLanguageSource _personLanguageSource ;
1215 private static PersonNameFirstFemaleSource _personNameFirstFemaleSource ;
1316 private static PersonNameFirstSource _personNameFirstSource ;
@@ -20,19 +23,35 @@ public static class NameEquivalenceClasses
2023 /// <summary>
2124 /// Generate and return an email address.
2225 /// </summary>
23- /// <param name="fixture">The fixture to generate a string for</param>
24- /// <returns>The generated string </returns>
26+ /// <param name="fixture">The fixture to generate a email for</param>
27+ /// <returns>The generated email </returns>
2528 public static string EmailAddress ( this AnonymousValueFixture fixture )
2629 {
2730 if ( _personEmailAddressSource == null ) _personEmailAddressSource = new PersonEmailAddressSource ( ) ;
2831 return _personEmailAddressSource . Next ( ) ;
2932 }
3033
34+ /// <summary>
35+ /// Generate and return a unique email address (within the fixture).
36+ /// </summary>
37+ /// <param name="fixture">The fixture to generate a unique email for</param>
38+ /// <returns>The generated unique email</returns>
39+ public static string UniqueEmailAddress ( this AnonymousValueFixture fixture )
40+ {
41+ if ( fixture . Bag . UniqueEmailAddressSource == null )
42+ {
43+ var generator = new SequentialGenerator ( 0 , _personEmailAddressSource . Data . Count , listShouldBeUnique : true ) ;
44+ fixture . Bag . UniqueEmailAddressSource = new PersonEmailAddressSource ( generator ) ;
45+ }
46+
47+ return fixture . Bag . UniqueEmailAddressSource . Next ( ) ;
48+ }
49+
3150 /// <summary>
3251 /// Generate and return a language name.
3352 /// </summary>
34- /// <param name="fixture">The fixture to generate a string for</param>
35- /// <returns>The generated string </returns>
53+ /// <param name="fixture">The fixture to generate a language for</param>
54+ /// <returns>The generated language </returns>
3655 public static string Language ( this AnonymousValueFixture fixture )
3756 {
3857 if ( _personLanguageSource == null ) _personLanguageSource = new PersonLanguageSource ( ) ;
@@ -42,8 +61,8 @@ public static string Language(this AnonymousValueFixture fixture)
4261 /// <summary>
4362 /// Generate and return a female first name.
4463 /// </summary>
45- /// <param name="fixture">The fixture to generate a string for</param>
46- /// <returns>The generated string </returns>
64+ /// <param name="fixture">The fixture to generate a first name for</param>
65+ /// <returns>The generated female first name </returns>
4766 public static string FemaleFirstName ( this AnonymousValueFixture fixture )
4867 {
4968 if ( _personNameFirstFemaleSource == null ) _personNameFirstFemaleSource = new PersonNameFirstFemaleSource ( ) ;
@@ -53,8 +72,8 @@ public static string FemaleFirstName(this AnonymousValueFixture fixture)
5372 /// <summary>
5473 /// Generate and return a male or female first name.
5574 /// </summary>
56- /// <param name="fixture">The fixture to generate a string for</param>
57- /// <returns>The generated string </returns>
75+ /// <param name="fixture">The fixture to generate a first name for</param>
76+ /// <returns>The generated first name </returns>
5877 public static string FirstName ( this AnonymousValueFixture fixture )
5978 {
6079 if ( _personNameFirstSource == null ) _personNameFirstSource = new PersonNameFirstSource ( ) ;
@@ -64,8 +83,8 @@ public static string FirstName(this AnonymousValueFixture fixture)
6483 /// <summary>
6584 /// Generate and return a male or female full name (first and last names).
6685 /// </summary>
67- /// <param name="fixture">The fixture to generate a string for</param>
68- /// <returns>The generated string </returns>
86+ /// <param name="fixture">The fixture to generate a full name for</param>
87+ /// <returns>The generated full name </returns>
6988 public static string FullName ( this AnonymousValueFixture fixture )
7089 {
7190 if ( _personNameFullSource == null ) _personNameFullSource = new PersonNameFullSource ( ) ;
@@ -75,8 +94,8 @@ public static string FullName(this AnonymousValueFixture fixture)
7594 /// <summary>
7695 /// Generate and return a last name.
7796 /// </summary>
78- /// <param name="fixture">The fixture to generate a string for</param>
79- /// <returns>The generated string </returns>
97+ /// <param name="fixture">The fixture to generate a last name for</param>
98+ /// <returns>The generated last name </returns>
8099 public static string LastName ( this AnonymousValueFixture fixture )
81100 {
82101 if ( _personNameLastSource == null ) _personNameLastSource = new PersonNameLastSource ( ) ;
@@ -86,8 +105,8 @@ public static string LastName(this AnonymousValueFixture fixture)
86105 /// <summary>
87106 /// Generate and return a male first name.
88107 /// </summary>
89- /// <param name="fixture">The fixture to generate a string for</param>
90- /// <returns>The generated string </returns>
108+ /// <param name="fixture">The fixture to generate a male first name for</param>
109+ /// <returns>The generated male first name </returns>
91110 public static string MaleFirstName ( this AnonymousValueFixture fixture )
92111 {
93112 if ( _personNameFirstMaleSource == null ) _personNameFirstMaleSource = new PersonNameFirstMaleSource ( ) ;
@@ -97,8 +116,8 @@ public static string MaleFirstName(this AnonymousValueFixture fixture)
97116 /// <summary>
98117 /// Generate and return name suffix.
99118 /// </summary>
100- /// <param name="fixture">The fixture to generate a string for</param>
101- /// <returns>The generated string </returns>
119+ /// <param name="fixture">The fixture to generate a suffix for</param>
120+ /// <returns>The generated suffix </returns>
102121 public static string Suffix ( this AnonymousValueFixture fixture )
103122 {
104123 if ( _personNameSuffixSource == null ) _personNameSuffixSource = new PersonNameSuffixSource ( ) ;
@@ -108,8 +127,8 @@ public static string Suffix(this AnonymousValueFixture fixture)
108127 /// <summary>
109128 /// Generate and return a name title.
110129 /// </summary>
111- /// <param name="fixture">The fixture to generate a string for</param>
112- /// <returns>The generated string </returns>
130+ /// <param name="fixture">The fixture to generate a title for</param>
131+ /// <returns>The generated title </returns>
113132 public static string Title ( this AnonymousValueFixture fixture )
114133 {
115134 if ( _personNameTitleSource == null ) _personNameTitleSource = new PersonNameTitleSource ( ) ;
0 commit comments