Skip to content

Commit fe3d824

Browse files
authored
Support custom Random seed value (StefH#14)
* wip * fix * Options.Seed ?? Environment.TickCount * LorumIpsumWords * 1.0.11-preview-01 * PackageLicenseExpression
1 parent e5c928d commit fe3d824

36 files changed

+3091
-128
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
</PropertyGroup>
55

66
<PropertyGroup>
7-
<VersionPrefix>1.0.10.0</VersionPrefix>
7+
<VersionPrefix>1.0.11-preview-01</VersionPrefix>
88
</PropertyGroup>
99
</Project>

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,4 @@ You can also use a UI to generate SQL insert table statements.
5353
- https://github.com/SaladLab/NetLegacySupport/tree/master/core/ConcurrentDictionary/System/Collections/Concurrent
5454

5555
### NuGet dependencies
56-
- NLipsum
5756
- Fare

src/ConsoleAppClassic/MainTest.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
using System;
1+
using RandomDataGenerator.FieldOptions;
2+
using RandomDataGenerator.Randomizers;
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using System.Reflection;
5-
using System.Text;
6-
using RandomDataGenerator.FieldOptions;
7-
using RandomDataGenerator.Randomizers;
87

98
namespace ConsoleAppClassic
109
{
1110
public static class MainTest
1211
{
1312
public static void Run()
1413
{
14+
var randomizerTextRegexWithSeed1 = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Seed = 12345, Pattern = @"^[1-9][0-9]{3}([A-RT-Z][A-Z]|[S][BCE-RT-Z])$" });
15+
string textRegexWithSeed1 = randomizerTextRegexWithSeed1.Generate();
16+
Write(randomizerTextRegexWithSeed1, textRegexWithSeed1);
17+
18+
var randomizerTextRegexWithSeed2 = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Seed = 12345, Pattern = @"^[1-9][0-9]{3}([A-RT-Z][A-Z]|[S][BCE-RT-Z])$" });
19+
string textRegexWithSeed2 = randomizerTextRegexWithSeed2.Generate();
20+
Write(randomizerTextRegexWithSeed2, textRegexWithSeed2);
21+
1522
var randomizerBytes = RandomizerFactory.GetRandomizer(new FieldOptionsBytes { Min = 10, Max = 20 });
1623
var base64 = randomizerBytes.GenerateAsBase64String();
1724
Write(randomizerBytes, base64);
@@ -28,6 +35,14 @@ public static void Run()
2835
string IBAN2 = randomizerIBAN2.Generate();
2936
Write(randomizerIBAN2, IBAN2);
3037

38+
var randomizerIBANWithSeed1 = RandomizerFactory.GetRandomizer(new FieldOptionsIBAN { Seed = 123, CountryCode = "NL" });
39+
string IBANWithSeed1 = randomizerIBANWithSeed1.Generate();
40+
Write(randomizerIBANWithSeed1, IBANWithSeed1);
41+
42+
var randomizerIBANWithSeed2 = RandomizerFactory.GetRandomizer(new FieldOptionsIBAN { Seed = 123, CountryCode = "NL" });
43+
string IBANWithSeed2 = randomizerIBANWithSeed2.Generate();
44+
Write(randomizerIBANWithSeed2, IBANWithSeed2);
45+
3146
var randomizerCity = RandomizerFactory.GetRandomizer(new FieldOptionsCity());
3247
string city = randomizerCity.Generate();
3348
Write(randomizerCity, city);

src/RandomDataGenerator/Data/ListData.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
using System.Reflection;
55
using System.Text;
66
using Fare;
7-
using RandomDataGenerator.TextData.Models;
7+
using RandomDataGenerator.Data.Models;
88

9-
namespace RandomDataGenerator.TextData
9+
namespace RandomDataGenerator.Data
1010
{
1111
internal sealed class ListData
1212
{
@@ -30,6 +30,10 @@ internal sealed class ListData
3030

3131
public IEnumerable<IBAN> BBANs { get; }
3232

33+
public IEnumerable<string> LoremIpsum { get; }
34+
35+
public IEnumerable<string> LoremIpsumWords { get; }
36+
3337
ListData()
3438
{
3539
LastNames = GetResourceAsLines("LastNames");
@@ -44,6 +48,8 @@ internal sealed class ListData
4448
Func<string[], IBAN> ibanFunc = (columns) => new IBAN { CountryName = columns[0], CountryCode = columns[1], Generator = new Xeger(columns[2]) };
4549
IBANs = GetResourceAsItems("IBAN", ibanFunc);
4650
BBANs = GetResourceAsItems("BBAN", ibanFunc);
51+
LoremIpsum = GetResourceAsLines("LoremIpsum");
52+
LoremIpsumWords = GetResourceAsLines("LorumIpsumWords");
4753
}
4854

4955
public static ListData Instance => Nested.TextInstance;

src/RandomDataGenerator/Data/Models/IBAN.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Fare;
22

3-
namespace RandomDataGenerator.TextData.Models
3+
namespace RandomDataGenerator.Data.Models
44
{
55
internal class IBAN
66
{

src/RandomDataGenerator/Data/Text/LoremIpsum.txt

Lines changed: 50 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)