Skip to content

Commit a2bb31a

Browse files
committed
Added default value supplier for emails
1 parent fc47c51 commit a2bb31a

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

NTestDataBuilder/AnonymousValueFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static AnonymousValueFixture()
1818
GlobalValueSuppliers = new List<IAnonymousValueSupplier>();
1919
DefaultValueSuppliers = new IAnonymousValueSupplier[]
2020
{
21+
new DefaultEmailValueSupplier(),
2122
new DefaultFirstNameValueSupplier(),
2223
new DefaultLastNameValueSupplier(),
2324
new DefaultStringValueSupplier(),

NTestDataBuilder/NTestDataBuilder.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<Compile Include="Lists\ListBuilderGenerator.cs" />
8787
<Compile Include="Lists\ListBuilderInterceptor.cs" />
8888
<Compile Include="PropertyNameGetter.cs" />
89+
<Compile Include="Suppliers\DefaultEmailValueSupplier.cs" />
8990
<Compile Include="Suppliers\DefaultLastNameValueSupplier.cs" />
9091
<Compile Include="Suppliers\DefaultFirstNameValueSupplier.cs" />
9192
<Compile Include="Suppliers\DefaultValueSupplier.cs" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using NTestDataBuilder.EquivalenceClasses;
2+
3+
namespace NTestDataBuilder.Suppliers
4+
{
5+
/// <summary>
6+
/// Supplies default anonymous value for email addresses.
7+
/// </summary>
8+
public class DefaultEmailValueSupplier : IAnonymousValueSupplier
9+
{
10+
/// <inheritdoc />
11+
public bool CanSupplyValue<TObject, TValue>(string propertyName)
12+
{
13+
return typeof (TValue) == typeof(string) && propertyName.ToLower().Contains("email");
14+
}
15+
16+
/// <inheritdoc />
17+
public TValue GenerateAnonymousValue<TObject, TValue>(AnonymousValueFixture any, string propertyName)
18+
{
19+
return (TValue) (object) any.PersonEmailAddress();
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)