Ejemplo n.º 1
0
        public void BracketOperator_RegexWithStringGroups_GroupValue()
        {
            // Arrange
            var someText         = "";
            var element          = new RegexFunctionElement(@"(?<numbers>([0-9])\w+)", RegexOptions.IgnoreCase, "numbers");
            var interfaceElement = (IRegexFunctionElement)element;

            // Act
            element.Match("test 123 some 456 test");
            var actual1 = element["numbers"];
            var actual2 = interfaceElement["numbers"];

            // Assert
            Assert.AreEqual("123", actual1);
            Assert.AreEqual("123", actual2);
        }
Ejemplo n.º 2
0
        public void BracketOperator_RegexWithIntegerGroups_GroupValue()
        {
            // Arrange
            var someText         = "";
            var element          = new RegexFunctionElement(@"\s([0-9]*)\s");
            var interfaceElement = (IRegexFunctionElement)element;

            // Act
            element.Match("test 123 some 456 test");
            var actual1 = element[1];
            var actual2 = interfaceElement[1];

            // Assert
            Assert.AreEqual("123", actual1);
            Assert.AreEqual("123", actual2);
        }
Ejemplo n.º 3
0
        public void Constructor_RegexWithStringGroups_GroupValue()
        {
            // Arrange
            var someText = "";
            var element  = new RegexFunctionElement(@"(?<numbers>([0-9])\w+)", RegexOptions.IgnoreCase, "numbers");

            // Act
            element.Match("test 123 some 456 test");
            var keys            = element.Keys;
            var defaultKeyValue = element.Value;

            // Assert
            Assert.AreEqual(3, element.Count);
            Assert.AreEqual(3, keys.Length);
            Assert.AreEqual(@"(?<numbers>([0-9])\w+)", element.Regex.ToString());
            Assert.AreEqual("123", defaultKeyValue);
        }