Skip to content

Commit 8b4bef6

Browse files
committed
Merge pull request #45 from Tynamix/ENHANCE_AddressPlugins
Added some new plugins for address generation
2 parents a7c8bf7 + e0bc6b3 commit 8b4bef6

File tree

13 files changed

+144
-28
lines changed

13 files changed

+144
-28
lines changed

ObjectFiller.Test/CityNamesPluginTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ namespace ObjectFiller.Test
22
{
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
44

5-
using Tynamix.ObjectFiller.Plugins.String;
5+
using Tynamix.ObjectFiller;
66

77
[TestClass]
88
public class CityNamesPluginTest
99
{
1010
[TestMethod]
1111
public void RandomNameIsReturned()
1212
{
13-
var sut = new CityNames();
13+
var sut = new CityName();
1414
var value = sut.GetValue();
1515

1616
Assert.IsFalse(string.IsNullOrEmpty(value));
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace ObjectFiller.Test
2+
{
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
5+
using Tynamix.ObjectFiller;
6+
7+
[TestClass]
8+
public class CountryNamesPlugin
9+
{
10+
[TestMethod]
11+
public void RandomNameIsReturned()
12+
{
13+
var sut = new CountryName();
14+
var value = sut.GetValue();
15+
16+
Assert.IsFalse(string.IsNullOrEmpty(value));
17+
}
18+
}
19+
}

ObjectFiller.Test/ObjectFiller.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
</ItemGroup>
4747
<ItemGroup>
4848
<Compile Include="AddressFillingTest.cs" />
49+
<Compile Include="CountryNamesPlugin.cs" />
4950
<Compile Include="CityNamesPluginTest.cs" />
5051
<Compile Include="CreateInstanceTest.cs" />
5152
<Compile Include="DefaultDatatypeMappingsTest.cs" />

ObjectFiller.Test/RandomizerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace ObjectFiller.Test
22
{
33
using System;
4+
using System.Linq;
45

56
using Microsoft.VisualStudio.TestTools.UnitTesting;
67

ObjectFiller.Test/StreetNamesPluginTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using Tynamix.ObjectFiller.Plugins.String;
32

43
namespace ObjectFiller.Test
54
{

ObjectFiller/ObjectFiller.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
<Reference Include="System.Core" />
3737
</ItemGroup>
3838
<ItemGroup>
39-
<Compile Include="Plugins\String\CityNames.cs" />
39+
<Compile Include="Plugins\String\CountryName.cs" />
4040
<Compile Include="Plugins\String\EmailAddresses.cs" />
41+
<Compile Include="Plugins\String\CityName.cs" />
4142
<Compile Include="Plugins\String\StreetName.cs" />
4243
<Compile Include="Plugins\String\Lipsum.cs" />
4344
<Compile Include="HashStack.cs" />
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="CityName.cs" company="Tynamix">
3+
// © 2015 by Hendrik Lösch and Roman Köhler
4+
// </copyright>
5+
// <summary>
6+
// Generate city name for type <see cref="string" />
7+
// </summary>
8+
// --------------------------------------------------------------------------------------------------------------------
9+
10+
namespace Tynamix.ObjectFiller
11+
{
12+
using System.Collections.Generic;
13+
using System.Linq;
14+
15+
using Tynamix.ObjectFiller.Properties;
16+
17+
/// <summary>
18+
/// Generate city names for type <see cref="string"/>. The Top 1000 cities with the most population will be used
19+
/// </summary>
20+
public class CityName : IRandomizerPlugin<string>
21+
{
22+
/// <summary>
23+
/// The names.
24+
/// </summary>
25+
protected static readonly List<string> AllCityNames;
26+
27+
/// <summary>
28+
/// Initializes static members of the <see cref="CityName"/> class.
29+
/// </summary>
30+
static CityName()
31+
{
32+
AllCityNames = Resources.cityNames.Split(';').ToList();
33+
}
34+
35+
/// <summary>
36+
/// Gets random data for type <see cref="T"/>
37+
/// </summary>
38+
/// <returns>Random data for type <see cref="T"/></returns>
39+
public string GetValue()
40+
{
41+
var index = Random.Next(AllCityNames.Count - 1);
42+
return AllCityNames[index];
43+
}
44+
}
45+
}

ObjectFiller/Plugins/String/CityNames.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="CountryName.cs" company="Tynamix">
3+
// © 2015 by Hendrik Lösch and Roman Köhler
4+
// </copyright>
5+
// <summary>
6+
// Generate country names for type <see cref="string" />
7+
// </summary>
8+
// --------------------------------------------------------------------------------------------------------------------
9+
10+
namespace Tynamix.ObjectFiller
11+
{
12+
using System.Collections.Generic;
13+
using System.Linq;
14+
15+
using Tynamix.ObjectFiller.Properties;
16+
17+
/// <summary>
18+
/// Generate country names for type <see cref="string"/>
19+
/// </summary>
20+
public class CountryName : IRandomizerPlugin<string>
21+
{
22+
/// <summary>
23+
/// The names.
24+
/// </summary>
25+
protected static readonly List<string> AllCountryNames;
26+
27+
/// <summary>
28+
/// Initializes static members of the <see cref="CountryName"/> class.
29+
/// </summary>
30+
static CountryName()
31+
{
32+
AllCountryNames = Resources.countryNames.Split(';').ToList();
33+
}
34+
35+
/// <summary>
36+
/// Gets random data for type <see cref="T"/>
37+
/// </summary>
38+
/// <returns>Random data for type <see cref="T"/></returns>
39+
public string GetValue()
40+
{
41+
var index = Random.Next(AllCountryNames.Count - 1);
42+
return AllCountryNames[index];
43+
}
44+
}
45+
}

ObjectFiller/Plugins/String/Lipsum.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ public enum LipsumFlavor
1111
/// Standard Lorem Ipsum words.
1212
/// </summary>
1313
LoremIpsum,
14+
1415
/// <summary>
1516
/// Words from Child Harold by Lord Byron.
1617
/// </summary>
1718
ChildHarold,
19+
1820
/// <summary>
1921
/// Words from In der Fremde by Heinrich Hiene (German)
2022
/// </summary>
2123
InDerFremde,
24+
2225
/// <summary>
2326
/// Words from Le Masque by Arthur Rembaud (French)
2427
/// </summary>

0 commit comments

Comments
 (0)