Click here to Skip to main content
13,145,464 members (53,938 online)
Click here to Skip to main content


124 bookmarked
Posted 29 Sep 2004

TextBoxRegex - A Text Box with Data Validation

, 29 Jun 2010
An enhanced text box control with powerful data validation capabilities
#region Copyright (c) 2004 Marek Grzenkowicz
 * Copyright (c) 2004 Marek Grzenkowicz
 * This software is provided 'as-is', without any warranty.
 * Permission is granted to anyone to use this software for any purpose.
 * This notice may not be removed from any source distibution; if you are
 * using this software in a product, this notice should be included in
 * materials distributed with your product.

using NUnit.Framework;

namespace Chopeen
    /// <summary>
    /// <exclude/>
    /// </summary>
    public class TestTextBoxRegexPattern
        private TextBoxRegex.Patterns pattern;

        public void CreatePatterns()
            pattern = new TextBoxRegex.Patterns();

        public void TestPatterns()
            Assert.AreEqual(0, (int) TextBoxRegex.Patterns.None);
            Assert.AreEqual(1, (int) TextBoxRegex.Patterns.SmallLetters);
            Assert.AreEqual(2, (int) TextBoxRegex.Patterns.CapitalLetters);
            Assert.AreEqual(4, (int) TextBoxRegex.Patterns.Digits);
            Assert.AreEqual(8, (int) TextBoxRegex.Patterns.NonAlphaNumericCharacters);
            Assert.AreEqual(16, (int) TextBoxRegex.Patterns.CharacterCollection);
            Assert.AreEqual(32, (int) TextBoxRegex.Patterns.WildcardPattern);
            Assert.AreEqual(64, (int) TextBoxRegex.Patterns.RegexPattern);
            Assert.AreEqual(15, (int) TextBoxRegex.Patterns.All);

        public void TestPatternAssignment()
            pattern = TextBoxRegex.Patterns.SmallLetters;
            Assert.AreEqual(TextBoxRegex.Patterns.SmallLetters, pattern);
            Assert.AreEqual(1, (int) pattern);

            pattern = TextBoxRegex.Patterns.CapitalLetters | TextBoxRegex.Patterns.NonAlphaNumericCharacters;
            Assert.AreEqual(TextBoxRegex.Patterns.CapitalLetters | TextBoxRegex.Patterns.NonAlphaNumericCharacters, pattern);
            Assert.AreEqual(10, (int) pattern);

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170915.1 | Last Updated 30 Jun 2010
Article Copyright 2004 by Marek Grzenkowicz
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid