Skip to content

Commit

Permalink
Support custom Random seed value (#14)
Browse files Browse the repository at this point in the history
* wip

* fix

* Options.Seed ?? Environment.TickCount

* LorumIpsumWords

* 1.0.11-preview-01

* PackageLicenseExpression
  • Loading branch information
StefH committed Apr 10, 2020
1 parent e5c928d commit fe3d824
Show file tree
Hide file tree
Showing 36 changed files with 3,091 additions and 128 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>1.0.10.0</VersionPrefix>
<VersionPrefix>1.0.11-preview-01</VersionPrefix>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ You can also use a UI to generate SQL insert table statements.
- https://github.com/SaladLab/NetLegacySupport/tree/master/core/ConcurrentDictionary/System/Collections/Concurrent

### NuGet dependencies
- NLipsum
- Fare
23 changes: 19 additions & 4 deletions src/ConsoleAppClassic/MainTest.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
using System;
using RandomDataGenerator.FieldOptions;
using RandomDataGenerator.Randomizers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using RandomDataGenerator.FieldOptions;
using RandomDataGenerator.Randomizers;

namespace ConsoleAppClassic
{
public static class MainTest
{
public static void Run()
{
var randomizerTextRegexWithSeed1 = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Seed = 12345, Pattern = @"^[1-9][0-9]{3}([A-RT-Z][A-Z]|[S][BCE-RT-Z])$" });
string textRegexWithSeed1 = randomizerTextRegexWithSeed1.Generate();
Write(randomizerTextRegexWithSeed1, textRegexWithSeed1);

var randomizerTextRegexWithSeed2 = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Seed = 12345, Pattern = @"^[1-9][0-9]{3}([A-RT-Z][A-Z]|[S][BCE-RT-Z])$" });
string textRegexWithSeed2 = randomizerTextRegexWithSeed2.Generate();
Write(randomizerTextRegexWithSeed2, textRegexWithSeed2);

var randomizerBytes = RandomizerFactory.GetRandomizer(new FieldOptionsBytes { Min = 10, Max = 20 });
var base64 = randomizerBytes.GenerateAsBase64String();
Write(randomizerBytes, base64);
Expand All @@ -28,6 +35,14 @@ public static void Run()
string IBAN2 = randomizerIBAN2.Generate();
Write(randomizerIBAN2, IBAN2);

var randomizerIBANWithSeed1 = RandomizerFactory.GetRandomizer(new FieldOptionsIBAN { Seed = 123, CountryCode = "NL" });
string IBANWithSeed1 = randomizerIBANWithSeed1.Generate();
Write(randomizerIBANWithSeed1, IBANWithSeed1);

var randomizerIBANWithSeed2 = RandomizerFactory.GetRandomizer(new FieldOptionsIBAN { Seed = 123, CountryCode = "NL" });
string IBANWithSeed2 = randomizerIBANWithSeed2.Generate();
Write(randomizerIBANWithSeed2, IBANWithSeed2);

var randomizerCity = RandomizerFactory.GetRandomizer(new FieldOptionsCity());
string city = randomizerCity.Generate();
Write(randomizerCity, city);
Expand Down
10 changes: 8 additions & 2 deletions src/RandomDataGenerator/Data/ListData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Reflection;
using System.Text;
using Fare;
using RandomDataGenerator.TextData.Models;
using RandomDataGenerator.Data.Models;

namespace RandomDataGenerator.TextData
namespace RandomDataGenerator.Data
{
internal sealed class ListData
{
Expand All @@ -30,6 +30,10 @@ internal sealed class ListData

public IEnumerable<IBAN> BBANs { get; }

public IEnumerable<string> LoremIpsum { get; }

public IEnumerable<string> LoremIpsumWords { get; }

ListData()
{
LastNames = GetResourceAsLines("LastNames");
Expand All @@ -44,6 +48,8 @@ internal sealed class ListData
Func<string[], IBAN> ibanFunc = (columns) => new IBAN { CountryName = columns[0], CountryCode = columns[1], Generator = new Xeger(columns[2]) };
IBANs = GetResourceAsItems("IBAN", ibanFunc);
BBANs = GetResourceAsItems("BBAN", ibanFunc);
LoremIpsum = GetResourceAsLines("LoremIpsum");
LoremIpsumWords = GetResourceAsLines("LorumIpsumWords");
}

public static ListData Instance => Nested.TextInstance;
Expand Down
2 changes: 1 addition & 1 deletion src/RandomDataGenerator/Data/Models/IBAN.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Fare;

namespace RandomDataGenerator.TextData.Models
namespace RandomDataGenerator.Data.Models
{
internal class IBAN
{
Expand Down
50 changes: 50 additions & 0 deletions src/RandomDataGenerator/Data/Text/LoremIpsum.txt

Large diffs are not rendered by default.

Loading

0 comments on commit fe3d824

Please sign in to comment.