Babel Class Library

Babel generates a string of random Unicode characters for input testing. The randomly generated string can contain between 1 and 100,000 characters composed of Unicode characters in the range of U+0020 through U+FFFF and U+100000 through U+10FFFF (surrogate pair characters), but excludes all special characters and undefined Unicode 5.1 code point ranges by default. This version features:

  • Updated to the Unicode 5.1 spec (including new script groups and character code points)
  • Custom range allows character generation from 0x01 through 0xFFFF.
  • Ability to generate strings with a max length of 100,000 characters
  • Improved distribution of characters from the selected language script groups

Click Here to Download the Babel Test Automation 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.

The Unicode language groups include: ASCII, African, American (Indian), Ancient, Arabic, Central Asian, Chinese Bopomofo, Ideographs, Cyrillic, European, Greek, Hebrew, Indic languages, Japanese (Kana), Korean, Other, Other Middle Eastern, Phillippine, Southeast Asian, Symbols, and Yi.

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.