Skip to content

Commit 46ee37f

Browse files
committed
Added example CompanySource and CompanyEquivalenceClass
1 parent 3b9d157 commit 46ee37f

5 files changed

Lines changed: 178 additions & 2 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using NTestDataBuilder.DataSources;
4+
using NTestDataBuilder.EquivalenceClasses;
5+
using Shouldly;
6+
using Xunit;
7+
8+
namespace NTestDataBuilder.Tests.EquivalenceClasses
9+
{
10+
public class CompanyEquivalenceClassTests
11+
{
12+
public AnonymousValueFixture Any { get; private set; }
13+
14+
public CompanyEquivalenceClassTests()
15+
{
16+
Any = new AnonymousValueFixture();
17+
}
18+
19+
[Fact]
20+
public void WhenGettingAnyCountry_ThenReturnRandomCompanyWhichIsReasonablyUnique()
21+
{
22+
var companySource = new CompanySource();
23+
24+
var results = new List<string>();
25+
for (int i = 0; i < 10; i++)
26+
{
27+
results.Add(Any.Company());
28+
}
29+
30+
foreach (var result in results)
31+
{
32+
result.ShouldBeOfType<string>();
33+
result.ShouldNotBeNullOrEmpty();
34+
companySource.List.ShouldContain(result);
35+
}
36+
var unique = results.Distinct().Count();
37+
unique.ShouldBeGreaterThan(5);
38+
}
39+
}
40+
}

NTestDataBuilder.Tests/NTestDataBuilder.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Include="DataSources\DataSourceTests.cs" />
5656
<Compile Include="DataSources\Generators\RandomGeneratorTests.cs" />
5757
<Compile Include="DataSources\Generators\SequentiaGeneratorTests.cs" />
58+
<Compile Include="EquivalenceClasses\CompanyEquivalenceClassTests.cs" />
5859
<Compile Include="EquivalenceClasses\StringEquivalenceClassesTests.cs" />
5960
<Compile Include="AsProxyTests.cs" />
6061
<Compile Include="BuildListTests.cs" />
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using System.Collections.Generic;
2+
using NTestDataBuilder.DataSources.Generators;
3+
4+
namespace NTestDataBuilder.DataSources
5+
{
6+
public class CompanySource : DataSource<string>
7+
{
8+
public CompanySource()
9+
: base() { }
10+
11+
public CompanySource(IGenerator generator)
12+
: base(generator) { }
13+
14+
protected override IList<string> InitializeList()
15+
{
16+
return new List<string>
17+
{
18+
"Wal-Mart Stores",
19+
"Exxon Mobil",
20+
"Chevron",
21+
"Phillips ",
22+
"Berkshire Hathaway",
23+
"Apple",
24+
"General Motors",
25+
"General Electric",
26+
"Valero Energy",
27+
"Ford Motor",
28+
"AT&T",
29+
"Fannie Mae",
30+
"CVS Caremark",
31+
"McKesson",
32+
"Hewlett-Packard",
33+
"Verizon Communications",
34+
"UnitedHealth Group",
35+
"J.P. Morgan Chase & Co.",
36+
"Cardinal Health",
37+
"International Business Machines",
38+
"Bank of America Corp.",
39+
"Costco Wholesale",
40+
"Kroger",
41+
"Express Scripts Holding",
42+
"Wells Fargo",
43+
"Citigroup",
44+
"Archer Daniels Midland",
45+
"Procter & Gamble",
46+
"Prudential Financial",
47+
"Boeing",
48+
"Freddie Mac",
49+
"AmerisourceBergen",
50+
"Marathon Petroleum",
51+
"Home Depot",
52+
"Microsoft",
53+
"Target",
54+
"Walgreen",
55+
"American International Group",
56+
"INTL FCStone",
57+
"MetLife",
58+
"Johnson & Johnson",
59+
"Caterpillar",
60+
"PepsiCo",
61+
"State Farm Insurance Cos.",
62+
"ConocoPhillips",
63+
"Comcast",
64+
"WellPoint",
65+
"Pfizer",
66+
"Amazon.com",
67+
"United Technologies",
68+
"Dell",
69+
"Dow Chemical",
70+
"United Parcel Service",
71+
"Intel",
72+
"Google",
73+
"Lowe's",
74+
"Coca-Cola",
75+
"Merck",
76+
"Lockheed Martin",
77+
"Cisco Systems",
78+
"Best Buy",
79+
"Safeway",
80+
"FedEx",
81+
"Enterprise Products Partners",
82+
"Sysco",
83+
"Walt Disney",
84+
"Johnson Controls",
85+
"Goldman Sachs Group",
86+
"CHS",
87+
"Abbott Laboratories",
88+
"Sears Holdings",
89+
"DuPont",
90+
"Humana",
91+
"World Fuel Services",
92+
"Hess",
93+
"Ingram Micro",
94+
"Plains All American Pipeline",
95+
"Honeywell International",
96+
"United Continental Holdings",
97+
"Oracle",
98+
"Liberty Mutual Insurance Group",
99+
"HCA Holdings",
100+
"Delta Air Lines",
101+
"Aetna",
102+
"Deere",
103+
"Supervalu",
104+
"Sprint Nextel",
105+
"Mondelēz International",
106+
"New York Life Insurance",
107+
"American Express",
108+
"News Corp.",
109+
"Allstate",
110+
"Tyson Foods",
111+
"Massachusetts Mutual Life Insurance",
112+
"Tesoro",
113+
"Morgan Stanley",
114+
"TIAA-CREF",
115+
"General Dynamics",
116+
"Philip Morris International",
117+
"Nationwide"
118+
};
119+
}
120+
}
121+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using NTestDataBuilder.DataSources;
2+
3+
namespace NTestDataBuilder.EquivalenceClasses
4+
{
5+
public static class CompanyEquivalenceClass
6+
{
7+
private static readonly CompanySource _companySource = new CompanySource();
8+
9+
public static string Company(this AnonymousValueFixture fixture)
10+
{
11+
return _companySource.Next();
12+
}
13+
}
14+
}

NTestDataBuilder/NTestDataBuilder.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
</ItemGroup>
5353
<ItemGroup>
5454
<Compile Include="AnonymousValueFixture.cs" />
55-
<Compile Include="DataSources\CalendarDaySource.cs" />
56-
<Compile Include="DataSources\CalendarUkSeasonSource.cs" />
55+
<Compile Include="DataSources\CompanySource.cs" />
5756
<Compile Include="DataSources\DataSource.cs" />
57+
<Compile Include="EquivalenceClasses\CompanyEquivalenceClass.cs" />
5858
<Compile Include="Guard.cs" />
5959
<Compile Include="DataSources\Generators\IGenerator.cs" />
6060
<Compile Include="DataSources\Generators\RandomGenerator.cs" />

0 commit comments

Comments
 (0)