Skip to content

Commit ae002bd

Browse files
committed
Added Geography data sources/equivalence classes. Established convention tests for all data sources.
1 parent 1e5fbe8 commit ae002bd

9 files changed

Lines changed: 101 additions & 75 deletions

File tree

NTestDataBuilder.Tests/DataSources/PersonSourceTests.cs renamed to NTestDataBuilder.Tests/DataSources/DataSourceConventionTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using NTestDataBuilder.DataSources;
4+
using NTestDataBuilder.DataSources.Geography;
45
using NTestDataBuilder.DataSources.Person;
56
using Shouldly;
67
using Xunit.Extensions;
78

89
namespace NTestDataBuilder.Tests.DataSources
910
{
10-
public class PersonSourceTests
11+
public class DataSourceConventionTests
1112
{
1213
[Theory]
1314
[PropertyData("TestCases")]
14-
public void PersonSourceSpec(DataSource<string> sut, int expectedCount)
15+
public void DataSourceConventions(DataSource<string> sut, int expectedCount)
1516
{
1617
var collection = sut.Data.ToList();
1718
collection.Count.ShouldBe(expectedCount);
@@ -23,6 +24,12 @@ public static IEnumerable<object[]> TestCases
2324
{
2425
get
2526
{
27+
yield return new object[] { new GeoContinentSource(), 7 };
28+
yield return new object[] { new GeoCountrySource(), 249 };
29+
yield return new object[] { new GeoCountryCodeSource(), 64 };
30+
yield return new object[] { new GeoLatitudeSource(), 1000 };
31+
yield return new object[] { new GeoLongitudeSource(), 1000 };
32+
2633
yield return new object[] { new PersonEmailAddressSource(), 1000 };
2734
yield return new object[] { new PersonLanguageSource(), 97 };
2835
yield return new object[] { new PersonNameFirstFemaleSource(), 100 };

NTestDataBuilder.Tests/EquivalenceClasses/DictionaryEquivalenceClassesTests.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@
33
using System.Linq;
44
using NTestDataBuilder.DataSources;
55
using NTestDataBuilder.DataSources.Geography;
6+
using NTestDataBuilder.DataSources.Person;
67
using NTestDataBuilder.EquivalenceClasses;
78
using Shouldly;
89
using Xunit.Extensions;
910

1011
namespace NTestDataBuilder.Tests.EquivalenceClasses
1112
{
12-
public class DictionaryEquivalenceClassesTests
13+
public class PersonEquivalenceClassesTests
1314
{
1415
public static AnonymousValueFixture Any { get; private set; }
1516

16-
public DictionaryEquivalenceClassesTests()
17+
public PersonEquivalenceClassesTests()
1718
{
1819
Any = new AnonymousValueFixture();
1920
}
2021

2122
[Theory]
2223
[PropertyData("TestCases")]
23-
public void WhenGettingAnyDictionaryData_ThenReturnRandomDictionaryDataWhichIsReasonablyUnique(DataSource<string> source,
24+
public void WhenGettingAnyPersonData_ThenReturnRandomPersonDataWhichIsReasonablyUnique(DataSource<string> source,
2425
List<string> testCases)
2526
{
2627
foreach (var testCase in testCases)
@@ -40,8 +41,21 @@ public static IEnumerable<object[]> TestCases
4041
{
4142
get
4243
{
44+
yield return new object[] { new PersonEmailAddressSource(), GenerateTestCasesForSut(Any.PersonEmailAddress) };
45+
yield return new object[] { new PersonLanguageSource(), GenerateTestCasesForSut(Any.PersonLanguage) };
46+
yield return new object[] { new PersonNameFirstFemaleSource(), GenerateTestCasesForSut(Any.PersonNameFirstFemale) };
47+
yield return new object[] { new PersonNameFirstSource(), GenerateTestCasesForSut(Any.PersonNameFirst) };
48+
yield return new object[] { new PersonNameFullSource(), GenerateTestCasesForSut(Any.PersonNameFull) };
49+
yield return new object[] { new PersonNameLastSource(), GenerateTestCasesForSut(Any.PersonNameLast) };
50+
yield return new object[] { new PersonNameFirstMaleSource(), GenerateTestCasesForSut(Any.PersonNameFirstMale) };
51+
yield return new object[] { new PersonNameSuffixSource(), GenerateTestCasesForSut(Any.PersonNameSuffix) };
52+
yield return new object[] { new PersonNameTitleSource(), GenerateTestCasesForSut(Any.PersonNameTitle) };
53+
4354
yield return new object[] { new GeoContinentSource(), GenerateTestCasesForSut(Any.GeoContinent) };
4455
yield return new object[] { new GeoCountrySource(), GenerateTestCasesForSut(Any.GeoCountry) };
56+
yield return new object[] { new GeoCountryCodeSource(), GenerateTestCasesForSut(Any.GeoCountryCode) };
57+
yield return new object[] { new GeoLatitudeSource(), GenerateTestCasesForSut(Any.GeoLatitude) };
58+
yield return new object[] { new GeoLongitudeSource(), GenerateTestCasesForSut(Any.GeoLongitude) };
4559
}
4660
}
4761

NTestDataBuilder.Tests/EquivalenceClasses/PersonEquivalenceClassesTests.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.

NTestDataBuilder.Tests/NTestDataBuilder.Tests.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@
5656
<Compile Include="DataSources\Dictionaries\CacheTests.cs" />
5757
<Compile Include="DataSources\Dictionaries\FileDictionaryRepositoryIntegrationTests.cs" />
5858
<Compile Include="DataSources\Dictionaries\FileDictionarySourceTests.cs" />
59-
<Compile Include="DataSources\Dictionaries\Resources\Class1.cs" />
59+
<Compile Include="DataSources\Dictionaries\Resources\FileDataConventions.cs" />
6060
<Compile Include="DataSources\Generators\RandomGeneratorTests.cs" />
6161
<Compile Include="DataSources\Generators\SequentiaGeneratorTests.cs" />
62-
<Compile Include="DataSources\PersonSourceTests.cs" />
62+
<Compile Include="DataSources\DataSourceConventionTests.cs" />
6363
<Compile Include="EquivalenceClasses\DictionaryEquivalenceClassesTests.cs" />
64-
<Compile Include="EquivalenceClasses\PersonEquivalenceClassesTests.cs" />
6564
<Compile Include="EquivalenceClasses\StringEquivalenceClassesTests.cs" />
6665
<Compile Include="AsProxyTests.cs" />
6766
<Compile Include="BuildListTests.cs" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using NTestDataBuilder.DataSources.Dictionaries;
2+
3+
namespace NTestDataBuilder.DataSources.Geography
4+
{
5+
/// <summary>
6+
/// Dictionary of country codes
7+
/// </summary>
8+
public class GeoCountryCodeSource : FileDictionarySource
9+
{
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using NTestDataBuilder.DataSources.Dictionaries;
2+
3+
namespace NTestDataBuilder.DataSources.Geography
4+
{
5+
/// <summary>
6+
/// Dictionary of latitude coordinates
7+
/// </summary>
8+
public class GeoLatitudeSource : FileDictionarySource
9+
{
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using NTestDataBuilder.DataSources.Dictionaries;
2+
3+
namespace NTestDataBuilder.DataSources.Geography
4+
{
5+
/// <summary>
6+
/// Dictionary of longitude coordinates codes
7+
/// </summary>
8+
public class GeoLongitudeSource : FileDictionarySource
9+
{
10+
}
11+
}

NTestDataBuilder/EquivalenceClasses/GeographyEquivalenceClassescs.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ namespace NTestDataBuilder.EquivalenceClasses
88
public static class GeographyEquivalenceClassescs
99
{
1010
private static GeoContinentSource _geoContinentSource;
11+
private static GeoCountrySource _geoCountrySource;
12+
private static GeoCountryCodeSource _geoCountryCodeSource;
13+
private static GeoLatitudeSource _geoLatitudeSource;
14+
private static GeoLongitudeSource _geoLongitudeSource;
1115

1216
/// <summary>
1317
/// Generate and return a continent name.
@@ -20,8 +24,6 @@ public static string GeoContinent(this AnonymousValueFixture fixture)
2024
return _geoContinentSource.Next();
2125
}
2226

23-
private static GeoCountrySource _geoCountrySource;
24-
2527
/// <summary>
2628
/// Generate and return a country name.
2729
/// </summary>
@@ -33,5 +35,38 @@ public static string GeoCountry(this AnonymousValueFixture fixture)
3335
return _geoCountrySource.Next();
3436
}
3537

38+
/// <summary>
39+
/// Generate and return a country code.
40+
/// </summary>
41+
/// <param name="fixture">The fixture to generate a string for</param>
42+
/// <returns>The generated string</returns>
43+
public static string GeoCountryCode(this AnonymousValueFixture fixture)
44+
{
45+
if (_geoCountryCodeSource == null) _geoCountryCodeSource = new GeoCountryCodeSource();
46+
return _geoCountryCodeSource.Next();
47+
}
48+
49+
50+
/// <summary>
51+
/// Generate and return a latitude coordinate.
52+
/// </summary>
53+
/// <param name="fixture">The fixture to generate a string for</param>
54+
/// <returns>The generated string</returns>
55+
public static string GeoLatitude(this AnonymousValueFixture fixture)
56+
{
57+
if (_geoLatitudeSource == null) _geoLatitudeSource = new GeoLatitudeSource();
58+
return _geoLatitudeSource.Next();
59+
}
60+
61+
/// <summary>
62+
/// Generate and return a longitude coordinate.
63+
/// </summary>
64+
/// <param name="fixture">The fixture to generate a string for</param>
65+
/// <returns>The generated string</returns>
66+
public static string GeoLongitude(this AnonymousValueFixture fixture)
67+
{
68+
if (_geoLongitudeSource == null) _geoLongitudeSource = new GeoLongitudeSource();
69+
return _geoLongitudeSource.Next();
70+
}
3671
}
3772
}

NTestDataBuilder/NTestDataBuilder.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@
5959
<Compile Include="DataSources\Dictionaries\CachedFileDictionaryRepository.cs" />
6060
<Compile Include="DataSources\Dictionaries\FileDictionarySource.cs" />
6161
<Compile Include="DataSources\Geography\GeoContinentSource.cs" />
62+
<Compile Include="DataSources\Geography\GeoCountryCodeSource.cs" />
6263
<Compile Include="DataSources\Geography\GeoCountrySource.cs" />
6364
<Compile Include="DataSources\DataSource.cs" />
65+
<Compile Include="DataSources\Geography\GeoLatitudeSource.cs" />
66+
<Compile Include="DataSources\Geography\GeoLongitudeSource.cs" />
6467
<Compile Include="DataSources\IDataSource.cs" />
6568
<Compile Include="DataSources\Person\PersonEmailAddressSource.cs" />
6669
<Compile Include="DataSources\Person\PersonLanguageSource.cs" />

0 commit comments

Comments
 (0)