Provides a column of random String values as a data source.
Namespace:
MbUnit.FrameworkAssembly: MbUnit (in MbUnit.dll) Version: 3.2.0.0 (3.2.528.0)
Syntax
| C# |
|---|
public class RandomStringsAttribute : GenerationDataAttribute |
| Visual Basic (Declaration) |
|---|
Public Class RandomStringsAttribute _ Inherits GenerationDataAttribute |
Remarks
Initialize the random string generator by setting the named parameter Count, which specifies how many random values to generate; and one of the two named parameters Pattern or Stock.
The Pattern property accepts a simplified regular expression syntax. The following syntactic features are supported:
- Logical Grouping : Group a part of the expression ((...)).
- Explicit Set : Define a set of possible characters ([...]). Ranges defined with a tiret are accepted.
- Explicit Quantifier : Specify the number of times the previous expression must be repeated. 'Constant' ({N}) or 'Range' ({N,M}) syntax are both accepted.
- Zero Or One Quantifier Metacharacter : 0 or 1 of the previous expression (?). Same effect as {0,1}.
- Escape Character : Makes the next character literal instead of a special character (\).
The Stock property selects a stock of predefined strings from which to draw random values.
Examples
[TestFixture] public class MyTestFixture { [Test] public void MyTestMethod([RandomStrings(Count = 3, Pattern = @"[A-Z]{5,8}")] string text) { // This test will run 3 times. It generates at each iteration // a random string containing 5 to 8 uppercase alphabetic characters. } }
Inheritance Hierarchy
System..::.Object
System..::.Attribute
Gallio.Framework.Pattern..::.PatternAttribute
Gallio.Framework.Pattern..::.DecoratorPatternAttribute
Gallio.Framework.Pattern..::.DataPatternAttribute
MbUnit.Framework..::.DataAttribute
MbUnit.Framework..::.GenerationDataAttribute
MbUnit.Framework..::.RandomStringsAttribute
System..::.Attribute
Gallio.Framework.Pattern..::.PatternAttribute
Gallio.Framework.Pattern..::.DecoratorPatternAttribute
Gallio.Framework.Pattern..::.DataPatternAttribute
MbUnit.Framework..::.DataAttribute
MbUnit.Framework..::.GenerationDataAttribute
MbUnit.Framework..::.RandomStringsAttribute
