diff --git a/README.md b/README.md index 67cc9bf..60e2e8d 100644 --- a/README.md +++ b/README.md @@ -24,24 +24,25 @@ A library and command line tool that can be used to generate data for testing, t ### Pattern Composition If you are familiar with Regular Expressions then most of the syntax used will be familiar but there are significant differences in place given that regex is used to match a string against a pattern. The generator instead uses simple patterns of symbols to produce strings, because of the difference in usage the syntaxes cannot match up entirely. Patterns define what the generated values will be and can be composed using text and symbols. Sections of the pattern can be repeated a specific number of times (they can also be repeated a random number of times by providing a min and max). Patterns can also include alternate items that will be randomly selected, helping to produce relatively complicated outputs. -### Symbols -The following symbols are shorthand tokens which you can use in your generation patterns: +### Symbols (Character Classes) +The following symbols are shorthand tokens which you can use in your generation patterns. They follow most of the [Perl/Tcl](http://en.wikipedia.org/wiki/Regular_expression#Character_classes) shorthand classifications but because our focus is on text production rather than searching/matching we have extended things a little with a few more shorthand items. |Symbol|Description|Represented characters| |------|-----------|-------| |`\.`|A single random character of any type.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 .,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/ and space| -|`\W`|A single random character from the following list ' .,;:\"'!&?£€$%^<>{}[]()*+-=\@#\|~/'.|? -|`\w`|A single random upper-case or lower-case letter.|g -|`\L`|A single random upper-case Letter.|M -|`\l`|A single random lower-case letter.|u -|`\V`|A single random upper-case Vowel.|O -|`\v`|A single random lower-case vowel.|i -|`\C`| - A single random upper-case Consonant.|K -|`\c`|A single random lower-case consonant.|y -|`\D`|A single random non number character.|i -|`\d`|A single random number, 1-9.|6 -|`\S`|A single random non-whitespace character|c -|`\s`|A whitespace character (Tab, New Line, Space, Carriage Return or Form Feed)| | +|`\w`|A single random upper-case character, lower-case character, number or underscore.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 or _| +|`\W`|A single random non AlphaNumeric, non Whitespace character|.,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/| +|`\a`|A single random upper-case character or lower-case character.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ| +|`\s`|A whitespace character|SPACE TAB NEWLINE CARRAIGERETURN VERTICALTAB LINEFEED| +|`\d`|A single random number|0-9| +|`\D`|A single random non number character.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ .,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/ or [SPACE]| +|`\l`|A single random lower-case letter.|abcdefghijklmnopqrstuvwxyz| +|`\L`|A single random upper-case Letter.|ABCDEFGHIJKLMNOPQRSTUVWXYZ| +|`\S`|A single random non-whitespace character.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 .,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/| +|`\V`|A single random upper-case Vowel.|AEIOU| +|`\v`|A single random lower-case vowel.|aeiou| +|`\C`|A single random upper-case Consonant.|BCDFGHJKLMNPQRSTVWXYZ| +|`\c`|A single random lower-case consonant.|bcdfghjklmnpqrstvwxyz| |`\n`|A newline character.|[NEWLINE]| |`\t`|A tab character.|[TAB]| @@ -51,9 +52,9 @@ Groups can contain multiple Symbols or characters and allows us to treat them as |Group|Description|Example| |----|------|-----| -|`(\d)`|A number between 0 and 9.|'3'| -|`(ABC\d)`|'ABC' followed by a number between 0 and 9.|ABC9| -|`\L(\d)\L`|A upper-case letter, three digits between 0 and 9 and another upper-case letter.|R6H| +|`(\d)`|A number between 0 and 9.|'2'| +|`(ABC\d)`|'ABC' followed by a number between 0 and 9.|ABC1| +|`\L(\d)\L`|A upper-case letter, three digits between 0 and 9 and another upper-case letter.|M7R| #### Alternations When a group contains alternations the patterns are divided by the | character, during processing one of the alternated patterns is selected at random. @@ -63,8 +64,8 @@ Groups can contain several individual symbols or groups of symbols and randomly |Alternation|Description|Example| |----|------|-----| -|`(\L\L|\d\d)`|Either two upper-case letters OR two numbers.|'77'| -|`(\L\L|\d\d|[AEIOU]|[100-120])`|Either two upper-case letters OR two digits OR an upper-case vowel OR a number between 100 and 120.|'103'| +|`(\L\L|\d\d)`|Either two upper-case letters OR two numbers.|'JY'| +|`(\L\L|\d\d|[AEIOU]|[100-120])`|Either two upper-case letters OR two digits OR an upper-case vowel OR a number between 100 and 120.|'QA'| |`(\C|)`|Either a upper-case Consonant or nothing.|| ### Ranges @@ -73,10 +74,10 @@ Ranges can contain multiple characters or ranges of characters but no symbols (t |Character Range|Description|Example| |----|------|-----| -|`[abc]`|Either 'a','b' or 'c'.|'b'| -|`[a-z]`|A single lower-case letter between a and z.|'e'| -|`[A-Z]`|A single upper-case letter between A and Z.|'H'| -|`[A-D]`|A single upper-case letter between A and D.|'D'| +|`[abc]`|Either 'a','b' or 'c'.|'a'| +|`[a-z]`|A single lower-case letter between a and z.|'z'| +|`[A-Z]`|A single upper-case letter between A and Z.|'R'| +|`[A-D]`|A single upper-case letter between A and D.|'C'| |`[A-Da-z]`|A single character between A and D or between a and z.|'s'| #### Numeric ranges @@ -84,13 +85,13 @@ Ranges can contain multiple characters or ranges of characters but no symbols (t |Numeric Range|Description|Example| |----|------|-----| |`[1-5]`|A number between 1 and 5.|'1'| -|`[100-500]`|A number between 100 and 500.|'423'| -|`[1.25-5]`|A decimal number between 1.25 and 5. The scope or number of decimal places is taken from the first number defined (1.25 in this case) and the produced value will have the same number of decimal places.|'1.48'| +|`[100-500]`|A number between 100 and 500.|'253'| +|`[1.25-5]`|A decimal number between 1.25 and 5. The scope or number of decimal places is taken from the first number defined (1.25 in this case) and the produced value will have the same number of decimal places.|'1.89'| ### Named Parameters A named pattern is surrounded with @ characters and links to a predefined pattern loaded from a file. The `default.tdg-patterns` file located in the same directory as the tdg executable file contains a list of named patterns which can be used in other patterns you write. For example to generate you could write something like `([1-9]\d\d-\d\d-\d\d\d\d)` or you can use the named parameter in the file `(@misc_ssn@)` to a similar value. You can add more patterns to the file as you wish. Named patterns can also include other named patterns if you so wish. -Take a look at the `@address_us_type1@` pattern in the file as an example of a compound pattern than uses other patterns to produce an output e.g. '374 Olive Place, Prince William County, Illinois, 35136' +Take a look at the `@address_us_type1@` pattern in the file as an example of a compound pattern than uses other patterns to produce an output e.g. '8579 Shady Lane, Howard County, Montana, 52963' ### Repetition Repetition is a powerful feature allowing for complicated data production. A Symbol, Group or Range can be repeated a set or random number of times by using the following syntax. @@ -99,17 +100,17 @@ Repetition is a powerful feature allowing for complicated data production. A Sym |Repitition syntax|Description|Example| |----|------|-----| -|`\d{5}`|Will generate 5 number characters.|'31909'| -|`(\L\d\L){5}`|Will generate 5 upper-case letter, number, upper-case letter items.|'M6BD2CI5HZ8UF1E'| -|`[ABC]{5}`|Will generate 5 items where each item will be either 'A','B' or 'C'.|'BCBCC'| +|`\d{5}`|Will generate 5 number characters.|'46642'| +|`(\L\d\L){5}`|Will generate 5 upper-case letter, number, upper-case letter items.|'J5EJ6KE9CZ4QB1F'| +|`[ABC]{5}`|Will generate 5 items where each item will be either 'A','B' or 'C'.|'AABAC'| #### Random Quantity |Random syntax|Description|Example| |----|------|-----| -|`\d{5,10}`|Will generate between 5 and 10 number characters.|'43043'| -|`(\L\d\L){5,10}`|Will generate between 5 and 10 upper-case letter, number, upper-case letter items.|'J0QV8UC0XF8MH1DJ4JO3B'| -|`[ABC]{5,10}`|Will generate between 5 and 10 items where each item will be either 'A','B' or 'C'.|'ABCAAC'| +|`\d{5,10}`|Will generate between 5 and 10 number characters.|'7211494791'| +|`(\L\d\L){5,10}`|Will generate between 5 and 10 upper-case letter, number, upper-case letter items.|'I0MJ3JA6VW7CA8FW4HD1J'| +|`[ABC]{5,10}`|Will generate between 5 and 10 items where each item will be either 'A','B' or 'C'.|'BBAAAAB'| ## Template Syntax @@ -119,7 +120,7 @@ You can create template documents that contain multiple pattern syntax placehold ### Placeholders You can place your symbols and patterns within placeholders which will be replaced with the generated values. These placeholders contain 1 or more symbols representing the desired output characters. -Within a template all text not within a placeholder is treated as normal text with no special handling taking place. Patterns that need to be randomly generated should be placed inside '<< >>' tokens e.g. 'This is a template <<\L\L>>' produces 'This is a template ZI'. You can also escape placeholders by placing a '\' before them which will prevent them from being processed. To place a '\' before a placeholder in the generated content you need to place 2 backslashes before the placeholder. +Within a template all text not within a placeholder is treated as normal text with no special handling taking place. Patterns that need to be randomly generated should be placed inside '<< >>' tokens e.g. 'This is a template <<\L\L>>' produces 'This is a template TE'. You can also escape placeholders by placing a '\' before them which will prevent them from being processed. To place a '\' before a placeholder in the generated content you need to place 2 backslashes before the placeholder. ### Configuration You can supply configuration values to the generator either as an additional parameter within the api or you can include it within the template string itself by wrapping it within '<# #>' tokens. Configuration directives must appear as the first item with a template or else they will be ignored and removed. @@ -159,15 +160,16 @@ Pattern files contain Named Patterns which can be used within Templates. TDG com |Command|Description|Example| |--------|--------|-------| -|`tdg -t 'Letters <<\L{20}>> and Numbers <<\d{12}>>'`|Single repeating symbols using the following syntax. |*'Letters ZQWSYOREAADBHFCYMVZD and Numbers 869032710662'*| -|`tdg -t '<<(\L){5}>>'`|Repeating patterns containing multiple letters or numbers of random length.
Will generate 5 random upper-case characters.|*'AOGFQ'*| -|`tdg -t '<<(\L\L\d){4}>>'`|Will generate 4 repeating letter-letter-number values.|*'PE5RI3NE9WB3'*| -|`tdg -t '<<(\L){10,20}>>'`|Will generate a string containing between 10 and 20 random upper-case characters.|*'SIWWMHTUJTUNCIKXBSY'*| -|`tdg -t 'Letters <<\L{2,20}>> and Numbers <<\d{2,12}>>'`|Produces items like|*'Letters HWQKLNIJWIIRVGZIJE and Numbers 948'*| -|`tdg -t 'Hi there <<\L\v{0,2}\l{0,2}\v \L\v{0,2}\l{0,2}\v{0,2}\l{0,2}\l>> how are you doing? Your SSN is <<[1-9]\d\d-\d\d-\d\d\d\d>>.' -c 100`|Input can contain several placeholders. Produces 100 items like|*'Hi there Foe Aaanv how are you doing?
Your SSN is 549-93-9041.'*| -|`tdg -t '<<[1-9]\d\d-\d\d-\d\d\d\d>>' -c 100`|Generate 100 SSN like values and output to console window. Produces 100 items like|*'830-58-6034'*| -|`tdg -t 'Hi there <<\L\v\l\v \L\v\l\l\v\v\l\l\v>> how are you doing?' -c 100 -o C:\test1.txt`|Generate 100 strings with random name like values and output to file. Produces 100 items like|*'Qeqe Hefpeapio'*| -|`tdg -t '<>'`|Produces the following output:|*'Letters P7Tj and Numbers 19 -'*| - -## This README was generated using the generator. See the unit tests for other examples. +|`tdg -t 'Letters <<\L{20}>> and Numbers <<\d{12}>>'`|Single repeating symbols using the following syntax. |*'Letters DWZIZQWSYOREAADBHFCY and Numbers 489186903271'*| +|`tdg -t '<<(\L){5}>>'`|Repeating patterns containing multiple letters or numbers of random length.
Will generate 5 random upper-case characters.|*'CRQGA'*| +|`tdg -t '<<(\L\L\d){4}>>'`|Will generate 4 repeating letter-letter-number values.|*'OG2QP1PR3JN1'*| +|`tdg -t '<<(\L){10,20}>>'`|Will generate a string containing between 10 and 20 random upper-case characters.|*'WBJVSIWWMHTUJTUNCIKX'*| +|`tdg -t 'Letters <<\L{2,20}>> and Numbers <<\d{2,12}>>'`|Produces items like|*'Letters SY and Numbers 38644533833'*| +|`tdg -t 'Hi there <<\L\v{0,2}\l{0,2}\v \L\v{0,2}\l{0,2}\v{0,2}\l{0,2}\l>> how are you doing? Your SSN is <<[1-9]\d\d-\d\d-\d\d\d\d>>.' -c 100`|Input can contain several placeholders. Produces 100 items like|*'Hi there Reue Emvue how are you doing?
Your SSN is 112-91-0458.'*| +|`tdg -t '<<[1-9]\d\d-\d\d-\d\d\d\d>>' -c 100`|Generate 100 SSN like values and output to console window. Produces 100 items like|*'549-93-9041'*| +|`tdg -t 'Hi there <<\L\v\l\v \L\v\l\l\v\v\l\l\v>> how are you doing?' -c 100 -o C:\test1.txt`|Generate 100 strings with random name like values and output to file. Produces 100 items like|*'Ruja Nuqaeiqfo how are you doing?'*| +|`tdg -t '<>'`|Produces the following output:|*'Letters svoLxlK and Numbers 71697'*| + +### Checkout the Examples folder for some further items and ideas. + +## This README was generated using the tdg. See the unit tests for other examples. diff --git a/VERSION b/VERSION index 6ccfdb8..fe9a89e 100644 Binary files a/VERSION and b/VERSION differ diff --git a/examples/RandomColouredDivs.html b/examples/RandomColouredDivs.html new file mode 100644 index 0000000..9e15cd8 --- /dev/null +++ b/examples/RandomColouredDivs.html @@ -0,0 +1,2028 @@ + + + + + + + + + +

+Generated with the following command 'tdg -i .\RandomColouredDivs.template -o RandomColouredDivs.html' +

+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ + diff --git a/examples/RandomColouredDivs.template b/examples/RandomColouredDivs.template new file mode 100644 index 0000000..e596c8c --- /dev/null +++ b/examples/RandomColouredDivs.template @@ -0,0 +1,28 @@ +<#{"seed":100}#> + + + + + + + + +

+Generated with the following command 'tdg -i .\RandomColouredDivs.template -o RandomColouredDivs.html' +

+
+ + <<(
\n){2000}>> + +
+ + \ No newline at end of file diff --git a/make.ps1 b/make.ps1 index 792b926..110bb8b 100644 --- a/make.ps1 +++ b/make.ps1 @@ -79,7 +79,7 @@ function test{ Write-host "TESTING FAILED!" -foregroundcolor:red $lastResult = $false } - $failedContent = ($content -match "^Failed") + $failedContent = ($content -match "Failed") $failedCount = $failedContent.Count if($failedCount -gt 0) { @@ -90,6 +90,18 @@ function test{ { write-host $line -foregroundcolor:red } + $failedContent = ($content -match "Not Runnable") + $failedCount = $failedContent.Count + if($failedCount -gt 0) + { + Write-host "TESTING FAILED!" -foregroundcolor:red + $lastResult = $false + } + Foreach ($line in $failedContent) + { + write-host $line -foregroundcolor:red + } + if($lastResult -eq $False){ exit } diff --git a/releases/tdg.3.4.2.0.nupkg b/releases/tdg.3.4.2.0.nupkg index 7a7c13a..5c449f2 100644 Binary files a/releases/tdg.3.4.2.0.nupkg and b/releases/tdg.3.4.2.0.nupkg differ diff --git a/src/DataGenerator/gk.DataGenerator.CommandLine/CommandLineArgs.cs b/src/DataGenerator/gk.DataGenerator.CommandLine/CommandLineArgs.cs index ca284f9..c997e57 100644 --- a/src/DataGenerator/gk.DataGenerator.CommandLine/CommandLineArgs.cs +++ b/src/DataGenerator/gk.DataGenerator.CommandLine/CommandLineArgs.cs @@ -35,20 +35,13 @@ internal class CommandLineArgs [Option('v', "verbose", DefaultValue = false, HelpText = "Verbose output including debug and performance information.", Required = false)] public bool Verbose { get; set; } - + [Option('n', "namedpatterns", DefaultValue = "", HelpText = "A list of ';' seperated file paths containing named patterns to be used in addition to default.tdg-patterns.", Required = false)] public string NamedPatterns { get; set; } [Option('l', "listnamedpatterns", DefaultValue = false, HelpText = "Outputs a list of the named patterns from the default.tdg-patterns file.", Required = false)] public bool ListNamedPatterns { get; set; } - - public CommandLineArgs() - { - //Random random = new Random(DateTime.Now.Millisecond); - //this.Seed = random.Next(int.MinValue, int.MaxValue); - } - [HelpOption] public string GetUsage() { @@ -56,7 +49,7 @@ public string GetUsage() var help = new HelpText { Heading = new HeadingInfo("Test Data Generator", assemblyName.Version.ToString()), - Copyright = new CopyrightInfo("Gary Kenneally (@SecretDeveloper)", 2014), + Copyright = new CopyrightInfo("Gary Kenneally (@SecretDeveloper)", 2015), AdditionalNewLineAfterOption = false, AddDashesToOption = true }; @@ -65,11 +58,11 @@ public string GetUsage() help.AddPreOptionsLine("Commandline Arguments:"); help.AddPostOptionsLine("Examples:"); - help.AddPostOptionsLine("\t tdg -t '<>'"); - help.AddPostOptionsLine("\t tdg -t '<>' -c 10"); - help.AddPostOptionsLine("\t tdg -t '<>' -o 'c:\\test.txt' -c 10"); + help.AddPostOptionsLine("\t tdg -t '<<\\L\\L>>'"); + help.AddPostOptionsLine("\t tdg -t '<<\\L\\L>>' -c 10"); + help.AddPostOptionsLine("\t tdg -t '<<\\L\\L>>' -o 'c:\\test.txt' -c 10"); help.AddPostOptionsLine("\t tdg -i 'c:\\input.txt' -o 'c:\\test.txt' -c 10"); - help.AddPostOptionsLine("Either a Template (-t), Pattern (-p) or input File (-i) value must be provided as input."); + help.AddPostOptionsLine("Either a template (-t), pattern (-p) or input file (-i) value must be provided as input."); help.AddOptions(this); return help; @@ -84,13 +77,14 @@ public string GetPatternUsage() sb.AppendLine("The following symbols can be used within a pattern to produce the desired output."); sb.AppendLine("\t\\. - A single random character of any type."); + sb.AppendLine("\t\\a - A single random upper-case or lower-case letter."); sb.AppendLine("\t\\W - A single random character from the following list ' .,;:'\"!&?£€$%^<>{}*+-=\\@#|~/'."); - sb.AppendLine("\t\\w - A single random upper-case or lower-case letter."); - sb.AppendLine("\t\\L - A single random upper-case Letter."); + sb.AppendLine("\t\\w - A single random upper-case, lower-case letter or number."); + sb.AppendLine("\t\\L - A single random upper-case letter."); sb.AppendLine("\t\\l - A single random lower-case letter."); sb.AppendLine("\t\\V - A single random upper-case Vowel."); sb.AppendLine("\t\\v - A single random lower-case vowel."); - sb.AppendLine("\t\\C - A single random upper-case Consonant."); + sb.AppendLine("\t\\C - A single random upper-case consonant."); sb.AppendLine("\t\\c - A single random lower-case consonant."); sb.AppendLine("\t\\D - A single random non number character."); sb.AppendLine("\t\\d - A single random number, 1-9."); @@ -106,9 +100,9 @@ public string GetPatternUsage() sb.AppendLine("Patterns and normal text can be combined in templates"); sb.AppendLine("Template usage"); - sb.AppendLine("\ttdg -t '<>'"); - sb.AppendLine("\ttdg -t '<>'"); - sb.AppendLine("\ttdg -t '<>'"); + sb.AppendLine("\ttdg -t 'Text containing a <<(\\L)>> pattern'"); + sb.AppendLine("\ttdg -t 'Text containing a <<(\\L){5}>> repeating pattern'"); + sb.AppendLine("\ttdg -t 'Text containing a <<(\\L){10,20}>> repeating pattern between 10 and 20 upper-case characters'"); sb.AppendLine("View the Readme document for further examples"); return sb.ToString(); diff --git a/src/DataGenerator/gk.DataGenerator.CommandLine/Program.cs b/src/DataGenerator/gk.DataGenerator.CommandLine/Program.cs index e200b43..3ee75ac 100644 --- a/src/DataGenerator/gk.DataGenerator.CommandLine/Program.cs +++ b/src/DataGenerator/gk.DataGenerator.CommandLine/Program.cs @@ -14,7 +14,8 @@ internal class Program private static void Main(string[] args) { var cla = new CommandLineArgs(); - Stopwatch sw = null; + Stopwatch sw = sw = new Stopwatch(); + sw.Start(); #if DEBUG Debugger.Launch(); @@ -33,12 +34,8 @@ private static void Main(string[] args) Console.Write(cla.GetPatternUsage()); return; } - - if (cla.Verbose) - { - sw = new Stopwatch(); - sw.Start(); - } + + if(cla.Verbose)Console.WriteLine("{0} - "); if (cla.ListNamedPatterns) { diff --git a/src/DataGenerator/gk.DataGenerator/Generators/AlphaNumericGenerator.cs b/src/DataGenerator/gk.DataGenerator/Generators/AlphaNumericGenerator.cs index b1bdb63..bd3f7f8 100644 --- a/src/DataGenerator/gk.DataGenerator/Generators/AlphaNumericGenerator.cs +++ b/src/DataGenerator/gk.DataGenerator/Generators/AlphaNumericGenerator.cs @@ -18,6 +18,7 @@ public static class AlphaNumericGenerator private const string _AllWhitespaceCharacters = " \t\n\r\f"; private const string _AllNonWhitespaceNonAlphaNumericCharacters = ".,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_|~/"; + private const string _ShortHand_a = _AllLetters; // \a private const string _ShortHand_l = "abcdefghijklmnopqrstuvwxyz"; // \l private const string _ShortHand_L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // \L private const string _ShortHand_V = "AEIOU"; // \V @@ -766,6 +767,9 @@ private static void AppendCharacterDerivedFromSymbol(StringBuilder sb, char symb case 'w': AppendRandomCharacterFromString(sb, _ShortHand_w, random); break; + case 'a': + AppendRandomCharacterFromString(sb, _ShortHand_a, random); + break; case 'L': AppendRandomCharacterFromString(sb, _ShortHand_L, random); break; @@ -797,7 +801,10 @@ private static void AppendCharacterDerivedFromSymbol(StringBuilder sb, char symb AppendRandomCharacterFromString(sb, _ShortHand_S, random); break; case 'n': - sb.Append(Environment.NewLine); + sb.Append("\n"); + break; + case 'r': + sb.Append("\r"); break; case 't': sb.Append("\t"); diff --git a/src/DataGenerator/gk.DataGeneratorTests/TextTests.cs b/src/DataGenerator/gk.DataGeneratorTests/TextTests.cs index 30b1ddc..3beef43 100644 --- a/src/DataGenerator/gk.DataGeneratorTests/TextTests.cs +++ b/src/DataGenerator/gk.DataGeneratorTests/TextTests.cs @@ -14,7 +14,7 @@ namespace gk.DataGeneratorTests [TestClass] [ExcludeFromCodeCoverage] [DeploymentItem(@"..\templates\README.template.md")] - [DeploymentItem(@"tdg-patterns\default.tdg-pattern")] + [DeploymentItem(@".\src\TestOutput\tdg-patterns\default.tdg-patterns")] public class TextTests { [TestMethod] @@ -26,7 +26,6 @@ public void Documentation_Builder() var text = AlphaNumericGenerator.GenerateFromTemplate(template); Console.WriteLine(text); - } #region Template @@ -1053,6 +1052,11 @@ public void Can_Generate_All_Symbols() Console.WriteLine(@"'{0}' produced '{1}'", pattern, text); StringAssert.Matches(text, new Regex(@"^.$")); + pattern = @"\a"; + text = AlphaNumericGenerator.GenerateFromPattern(pattern); + Console.WriteLine(@"'{0}' produced '{1}'", pattern, text); + StringAssert.Matches(text, new Regex(@"^[A-Za-z]$")); + pattern = @"\W"; text = AlphaNumericGenerator.GenerateFromPattern(pattern); Console.WriteLine(@"'{0}' produced '{1}'", pattern, text); @@ -1113,6 +1117,16 @@ public void Can_Generate_All_Symbols() Console.WriteLine(@"'{0}' produced '{1}'", pattern, text.ToLiteral()); StringAssert.Matches(text, new Regex(@"^\t$")); + pattern = @"\n"; + text = AlphaNumericGenerator.GenerateFromPattern(pattern); + Console.WriteLine(@"'{0}' produced '{1}'", pattern, text.ToLiteral()); + StringAssert.Matches(text, new Regex(@"^\n$")); + + pattern = @"\r"; + text = AlphaNumericGenerator.GenerateFromPattern(pattern); + Console.WriteLine(@"'{0}' produced '{1}'", pattern, text.ToLiteral()); + StringAssert.Matches(text, new Regex(@"^\r$")); + pattern = @"\\"; text = AlphaNumericGenerator.GenerateFromPattern(pattern); Console.WriteLine(@"'{0}' produced '{1}'", pattern, text.ToLiteral()); diff --git a/src/templates/README.template.md b/src/templates/README.template.md index 4c31c07..7faa673 100644 --- a/src/templates/README.template.md +++ b/src/templates/README.template.md @@ -24,24 +24,25 @@ A library and command line tool that can be used to generate data for testing, t ### Pattern Composition If you are familiar with Regular Expressions then most of the syntax used will be familiar but there are significant differences in place given that regex is used to match a string against a pattern. The generator instead uses simple patterns of symbols to produce strings, because of the difference in usage the syntaxes cannot match up entirely. Patterns define what the generated values will be and can be composed using text and symbols. Sections of the pattern can be repeated a specific number of times (they can also be repeated a random number of times by providing a min and max). Patterns can also include alternate items that will be randomly selected, helping to produce relatively complicated outputs. -### Symbols -The following symbols are shorthand tokens which you can use in your generation patterns: +### Symbols (Character Classes) +The following symbols are shorthand tokens which you can use in your generation patterns. They follow most of the [Perl/Tcl](http://en.wikipedia.org/wiki/Regular_expression#Character_classes) shorthand classifications but because our focus is on text production rather than searching/matching we have extended things a little with a few more shorthand items. |Symbol|Description|Represented characters| |------|-----------|-------| |`\.`|A single random character of any type.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 .,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/ and space| -|`\W`|A single random character from the following list ' .,;:\"'!&?£€$%^<>{}[]()*+-=\@#\|~/'.|<<\W>> -|`\w`|A single random upper-case or lower-case letter.|<<\w>> -|`\L`|A single random upper-case Letter.|<<\L>> -|`\l`|A single random lower-case letter.|<<\l>> -|`\V`|A single random upper-case Vowel.|<<\V>> -|`\v`|A single random lower-case vowel.|<<\v>> -|`\C`| - A single random upper-case Consonant.|<<\C>> -|`\c`|A single random lower-case consonant.|<<\c>> -|`\D`|A single random non number character.|<<\D>> -|`\d`|A single random number, 1-9.|<<\d>> -|`\S`|A single random non-whitespace character|<<\S>> -|`\s`|A whitespace character (Tab, New Line, Space, Carriage Return or Form Feed)|<<\s>>| +|`\w`|A single random upper-case character, lower-case character, number or underscore.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 or _| +|`\W`|A single random non AlphaNumeric, non Whitespace character|.,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/| +|`\a`|A single random upper-case character or lower-case character.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ| +|`\s`|A whitespace character|SPACE TAB NEWLINE CARRAIGERETURN VERTICALTAB LINEFEED| +|`\d`|A single random number|0-9| +|`\D`|A single random non number character.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ .,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/ or [SPACE]| +|`\l`|A single random lower-case letter.|abcdefghijklmnopqrstuvwxyz| +|`\L`|A single random upper-case Letter.|ABCDEFGHIJKLMNOPQRSTUVWXYZ| +|`\S`|A single random non-whitespace character.|abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 .,;:\"'!&?£$€$%^<>{}[]()*\\+-=@#_\|~/| +|`\V`|A single random upper-case Vowel.|AEIOU| +|`\v`|A single random lower-case vowel.|aeiou| +|`\C`|A single random upper-case Consonant.|BCDFGHJKLMNPQRSTVWXYZ| +|`\c`|A single random lower-case consonant.|bcdfghjklmnpqrstvwxyz| |`\n`|A newline character.|[NEWLINE]| |`\t`|A tab character.|[TAB]| @@ -166,7 +167,9 @@ Pattern files contain Named Patterns which can be used within Templates. TDG com |`tdg -t 'Letters \<<\L{2,20}>> and Numbers \<<\d{2,12}>>'`|Produces items like|*'Letters <<\L{2,20}>> and Numbers <<\d{2,12}>>'*| |`tdg -t 'Hi there \<<\L\v{0,2}\l{0,2}\v \L\v{0,2}\l{0,2}\v{0,2}\l{0,2}\l>> how are you doing? Your SSN is \<<[1-9]\d\d-\d\d-\d\d\d\d>>.' -c 100`|Input can contain several placeholders. Produces 100 items like|*'Hi there <<\L\v{0,2}\l{0,2}\v \L\v{0,2}\l{0,2}\v{0,2}\l{0,2}\l>> how are you doing?
Your SSN is <<[1-9]\d\d-\d\d-\d\d\d\d>>.'*| |`tdg -t '\<<[1-9]\d\d-\d\d-\d\d\d\d>>' -c 100`|Generate 100 SSN like values and output to console window. Produces 100 items like|*'<<[1-9]\d\d-\d\d-\d\d\d\d>>'*| -|`tdg -t 'Hi there \<<\L\v\l\v \L\v\l\l\v\v\l\l\v>> how are you doing?' -c 100 -o C:\test1.txt`|Generate 100 strings with random name like values and output to file. Produces 100 items like|*'<<\L\v\l\v \L\v\l\l\v\v\l\l\v>>'*| -|`tdg -t '\<>'`|Produces the following output:|*'<>'*| +|`tdg -t 'Hi there \<<\L\v\l\v \L\v\l\l\v\v\l\l\v>> how are you doing?' -c 100 -o C:\test1.txt`|Generate 100 strings with random name like values and output to file. Produces 100 items like|*'<<\L\v\l\v \L\v\l\l\v\v\l\l\v>> how are you doing?'*| +|`tdg -t '\<>'`|Produces the following output:|*'<>'*| -## This README was generated using the generator. See the unit tests for other examples. \ No newline at end of file +### Checkout the Examples folder for some further items and ideas. + +## This README was generated using the tdg. See the unit tests for other examples. \ No newline at end of file