Testing Mentor Class Library


Click here to download Babel Library

Babel 3.0 Members

Generates a random Unicode string based on parameterized equivalent partitions.

Constructor

  Name Description
StringGenerator Initializes a new instance of the StringGenerator class

Methods

  Name Description
Polyglot Generates a random string of Unicode characters parameterized by the StringInfo information

Properties

  Name Description
StringInfo Sets the properties to pass to the Polyglot method of the StringGenerator
LanuageGroup Sets the set of characters used in the test data string to a specific language group.
SpecialCharacter Sets the type of special character to insert into the test data string.
CharacterPosition Sets the position of the special character in the string.

Remarks

If the StringInfo.Seed value is less than 0 Polyglot will throw an ArgumentException.

If the StringInfo.UnicodeStartRange is greater than the StringInfo.UnicodeEndRange Polyglot will throw an ArgumentException.

If the StringInfo.LanguageGroup is less than 0 or greater than 20 Polyglot will throw an ArgumentException.

Example

using System;
using TestingMentor.TestTool.Babel;

namespace RandomTestDataGeneratorExample
{
  class RandomUnicodeString
  {
    static void Main()
    {
      // Generate a random seed value for the pseudo-random
      // generator

      Random r = new Random();
      int seedValue = r.Next();
      // Log seedValue variable to be able to regenerate identical
      // string

      StringGenerator sg = new StringGenerator();
      sg.Info.Seed = seedValue;     
      sg.Info.IsSendKeysSafe = true;
      sg.Info.MaximumCharacterCount = 50;
      sg.Info.RandomizeCharacterCount = true;
      sg.Info.AllowSurrogateCharacters = true;

      string testData = sg.Polyglot
    }
  }
}

This example returns a string of randomly generated characters distributed across all Unicode language groups with a character count of between 1 and 50 characters, and may contain Unicode surrogate pair characters. The string excludes characters that are special characters to C#'s SendKeys class members.

Example

using System;
using TestingMentor.TestTool.Babel;

namespace RandomTestDataGeneratorExample
{
  class RandomUnicodeString
  {
    static void Main()
    {
      // Generate a random seed value for the pseudo-random
      // generator

      Random r = new Random();
      int seedValue = r.Next();
      // Log seedValue variable to be able to regenerate identical
      // string

      StringGenerator sg = new StringGenerator();
      sg.Info.Seed = seedValue;     
      sg.Info.IsSendKeysSafe = true;
      sg.Info.MaximumCharacterCount = 50;
      sg.Info.RandomizeCharacterCount = false;
      sg.Info.InjectSpecialCharacter =
     (int)StringGenerator.SpecialCharacter.SurrogatePairCharacter;
      sg.Info.SpecialCharacterPosition =
        (int)StringGenerator.CharacterPosition.Random;

      string testData = sg.Polyglot
    }
  }
}

This example returns a string of randomly generated characters distributed across all Unicode language groups with a character count of 50 characters, and contains at least one Unicode surrogate pair character. The string excludes characters that are special characters to C#'s SendKeys class members.

Example

using System;
using TestingMentor.TestTool.Babel;

namespace RandomTestDataGeneratorExample
{
  class RandomUnicodeString
  {
    static void Main()
    {
      // Generate a random seed value for the pseudo-random
      // generator

      Random r = new Random();
      int seedValue = r.Next();
      // Log seedValue variable to be able to regenerate identical
      // string

      StringGenerator sg = new StringGenerator();
      sg.Info.Seed = seedValue;     
      sg.Info.IsSendKeysSafe = true;
      sg.Info.MaximumCharacterCount = 50;
      sg.Info.LanguageGroup =
        (int)StringGenerator.LanguageGroup.Cyrillic;

      string testData = sg.Polyglot
    }
  }
}

This example illustrates how to generate a string of characters for a specific language family. This example returns a string of 50 randomly generated characters in the Cyrillic language families, but excludes characters that are special characters to C# SendKeys class members.

Example

using System;
using TestingMentor.TestTool.Babel;

namespace RandomTestDataGeneratorExample
{
  class RandomUnicodeString
  {
    static void Main()
    {
      // Generate a random seed value for the pseudo-random
      // generator

      Random r = new Random();
      int seedValue = r.Next();
      // Log seedValue variable to be able to regenerate identical
      // string

      StringGenerator sg = new StringGenerator();
      sg.Info.Seed = seedValue;     
      sg.Info.MaximumCharacterCount = 50;
      sg.Info.UseCustomRange = true;
      sg.Info.UnicodeStartRange = '\u0000';
      sg.Info.UnicodeEndRange = '\u0100';
      sg.Info.AllowControlCharacters = true;

      string testData = sg.Polyglot
    }
  }
}

This example illustrates how to generate a string of characters within a specified range of Unicode character code points. This example  returns a string of 50 randomly generated characters between Unicode code point values of U+0000 and U+0100 and the string may include control characters, and does not exclude characters that have special meaning to C#'s SendKeys class.