1- using System ;
2- using System . Collections . Generic ;
1+ using System . Collections . Generic ;
32using System . Linq ;
43using Shouldly ;
54using TestStack . Dossier . DataSources ;
98
109namespace TestStack . Dossier . Tests . EquivalenceClasses
1110{
12- public class PersonEquivalenceClassesTests
11+ public class PersonEquivalenceClassesTests : FileDictionaryEquivalenceTests
1312 {
14- public static AnonymousValueFixture Any { get ; } = new AnonymousValueFixture ( ) ;
13+ public AnonymousValueFixture Any { get ; } = new AnonymousValueFixture ( ) ;
1514
1615 [ Theory ]
17- [ PropertyData ( "TestCases" ) ]
18- public void WhenGettingAnyPersonData_ThenReturnRandomPersonDataWhichIsReasonablyUnique ( DataSource < string > source ,
19- List < string > testCases )
16+ [ ClassData ( typeof ( PersonTestCases ) ) ]
17+ public override void WhenGettingAnyData_ThenReturnRandomDataWhichIsReasonablyUnique ( DataSource < string > source , List < string > testCases )
2018 {
21- foreach ( var testCase in testCases )
22- {
23- testCase . ShouldBeOfType < string > ( ) ;
24- testCase . ShouldNotBeNullOrEmpty ( ) ;
25- source . Data . ShouldContain ( testCase ) ;
26- }
27- if ( source . Data . Count > 15 )
28- {
29- var unique = testCases . Distinct ( ) . Count ( ) ;
30- unique . ShouldBeGreaterThan ( 5 ) ;
31- }
19+ base . WhenGettingAnyData_ThenReturnRandomDataWhichIsReasonablyUnique ( source , testCases ) ;
3220 }
3321
3422 [ Fact ]
@@ -47,31 +35,27 @@ public void WhenGettingUniqueEmail_ThenReturnUniqueEmailsAcrossFixtureInstances(
4735 generatedValues . Distinct ( ) . Count ( )
4836 . ShouldBe ( generatedValues . Count ) ;
4937 }
38+ }
5039
51- public static IEnumerable < object [ ] > TestCases
40+ public class PersonTestCases : FileDictionaryEquivalenceTestCases
41+ {
42+ protected override List < object [ ] > GetData ( )
5243 {
53- get
44+ return new List < object [ ] >
5445 {
55- yield return new object [ ] { new Words ( FromDictionary . PersonEmailAddress ) , GenerateTestCasesForSut ( Any . PersonEmailAddress ) } ;
56- yield return new object [ ] { new Words ( FromDictionary . PersonLanguage ) , GenerateTestCasesForSut ( Any . PersonLanguage ) } ;
57- yield return new object [ ] { new Words ( FromDictionary . PersonNameFirstFemale ) , GenerateTestCasesForSut ( Any . PersonNameFirstFemale ) } ;
58- yield return new object [ ] { new Words ( FromDictionary . PersonNameFirst ) , GenerateTestCasesForSut ( Any . PersonNameFirst ) } ;
59- yield return new object [ ] { new Words ( FromDictionary . PersonNameFull ) , GenerateTestCasesForSut ( Any . PersonNameFull ) } ;
60- yield return new object [ ] { new Words ( FromDictionary . PersonNameLast ) , GenerateTestCasesForSut ( Any . PersonNameLast ) } ;
61- yield return new object [ ] { new Words ( FromDictionary . PersonNameFirstMale ) , GenerateTestCasesForSut ( Any . PersonNameFirstMale ) } ;
62- yield return new object [ ] { new Words ( FromDictionary . PersonNameSuffix ) , GenerateTestCasesForSut ( Any . PersonNameSuffix ) } ;
63- yield return new object [ ] { new Words ( FromDictionary . PersonNameTitle ) , GenerateTestCasesForSut ( Any . PersonNameTitle ) } ;
64- }
46+ new object [ ]
47+ { new Words ( FromDictionary . PersonEmailAddress ) , GenerateTestCasesForSut ( Any . PersonEmailAddress ) } ,
48+ new object [ ] { new Words ( FromDictionary . PersonLanguage ) , GenerateTestCasesForSut ( Any . PersonLanguage ) } ,
49+ new object [ ]
50+ { new Words ( FromDictionary . PersonNameFirstFemale ) , GenerateTestCasesForSut ( Any . PersonNameFirstFemale ) } ,
51+ new object [ ] { new Words ( FromDictionary . PersonNameFirst ) , GenerateTestCasesForSut ( Any . PersonNameFirst ) } ,
52+ new object [ ] { new Words ( FromDictionary . PersonNameFull ) , GenerateTestCasesForSut ( Any . PersonNameFull ) } ,
53+ new object [ ] { new Words ( FromDictionary . PersonNameLast ) , GenerateTestCasesForSut ( Any . PersonNameLast ) } ,
54+ new object [ ]
55+ { new Words ( FromDictionary . PersonNameFirstMale ) , GenerateTestCasesForSut ( Any . PersonNameFirstMale ) } ,
56+ new object [ ] { new Words ( FromDictionary . PersonNameSuffix ) , GenerateTestCasesForSut ( Any . PersonNameSuffix ) } ,
57+ new object [ ] { new Words ( FromDictionary . PersonNameTitle ) , GenerateTestCasesForSut ( Any . PersonNameTitle ) } ,
58+ } ;
6559 }
66-
67- private static List < string > GenerateTestCasesForSut ( Func < string > any )
68- {
69- var results = new List < string > ( ) ;
70- for ( int i = 0 ; i < 10 ; i ++ )
71- {
72- results . Add ( any ( ) ) ;
73- }
74- return results ;
75- }
7660 }
7761}
0 commit comments