1- using Ploeh . AutoFixture ;
1+ using System . Text ;
2+ using Ploeh . AutoFixture ;
23using Ploeh . AutoFixture . Kernel ;
34
45namespace NTestDataBuilder . EquivalenceClasses
@@ -19,9 +20,11 @@ public static string String(this AnonymousValueFixture fixture)
1920 }
2021
2122 /// <summary>
22- /// Generate and return a string.
23+ /// Generate and return a string matching the given regex.
24+ /// Only a limited subset of regex expressions are supported: http://www.brics.dk/automaton/faq.html.
2325 /// </summary>
2426 /// <param name="fixture">The fixture to generate a string for</param>
27+ /// <param name="regexPattern">The regex pattern to match</param>
2528 /// <returns>The generated string</returns>
2629 public static string StringMatching ( this AnonymousValueFixture fixture , string regexPattern )
2730 {
@@ -49,5 +52,21 @@ public static string StringEndingWith(this AnonymousValueFixture fixture, string
4952 {
5053 return string . Format ( "{0}{1}" , fixture . Fixture . Create < string > ( ) , suffix ) ;
5154 }
55+
56+ /// <summary>
57+ /// Generate and return a string of the given length.
58+ /// </summary>
59+ /// <param name="fixture">The fixture to generate a string for</param>
60+ /// <param name="length">The length of string to generate</param>
61+ /// <returns>The generated string</returns>
62+ public static string StringOfLength ( this AnonymousValueFixture fixture , int length )
63+ {
64+ var sb = new StringBuilder ( ) ;
65+ while ( sb . Length < length )
66+ {
67+ sb . Append ( String ( fixture ) ) ;
68+ }
69+ return sb . ToString ( ) . Substring ( 0 , length ) ;
70+ }
5271 }
5372}
0 commit comments