public void AnyCharacter()
        {
            // ARRANGE
            const string regex = @".";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var actuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(1, actuals.Length);
            var actual = actuals[0];
            Assert.IsInstanceOfType(actual.Tag, typeof(SpecialCharacter));
            Assert.AreEqual("Any character", ((SpecialCharacter)actual.Tag).Description);
        }
        public void AnyChracterInClass()
        {
            // ARRANGE
            const string regex = @"[0-9]";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var actuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(1, actuals.Length);
            var actual = actuals[0].Tag;
            Assert.AreEqual("Any character in this class: [0-9]", actual.Description);
        }
        public void TwoAlternatives()
        {
            // ARRANGE
            const string regex = @"[a-z]{1,2}\d[A-Z]|[A-Z]{1,2}\d{1,2}";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var topLevelActuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(1, topLevelActuals.Length);
            var alternatives = ((Alternatives) (topLevelActuals[0].Tag));
            Assert.AreEqual(2, alternatives.Count);
        }
        public void UpperCaseTwoRepititions()
        {
            // ARRANGE
            const string regex = @"A-Z{2}";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var actuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(3, actuals.Length);
            Assert.AreEqual("A", actuals[0].Tag.Description);
            Assert.AreEqual("-", actuals[1].Tag.Description);
            Assert.AreEqual("Z", actuals[2].Tag.Description);
        }
        public void NamedCaptureGroup()
        {
            // ARRANGE
            const string regex = @"(?<AnimalName>[\w ])";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var actuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(1, actuals.Length);
            var actual = actuals[0].Tag;
            Assert.IsInstanceOfType(actual, typeof(Group));
            Assert.AreEqual("AnimalName", ((Group)actual).Name);
        }
        public void MatchSuffixButExcludeItFromCapture()
        {
            // ARRANGE
            const string regex = @"(?=(?:.*?[A-Z]){2})";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var actuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(1, actuals.Length);
            var actual = actuals[0].Tag;
            Assert.IsInstanceOfType(actual, typeof(Group));
            Assert.AreEqual(GroupType.SuffixPresent, ((Group)actuals[0].Tag).Type);
        }
        public void EndOfLineOrString()
        {
            // ARRANGE
            const string regex = @"$";

            const string expected = "End of line or string";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);
            TreeNode<Element>[] nodes = expression.GetNodes();

            // ACT
            var actual = nodes[0].Tag.Description;

            // ASSERT
            Assert.AreEqual(1, nodes.Length);
            Assert.AreEqual(expected, actual);
        }
        public void BeginningLiteralAndEndOfLineOrString()
        {
            // ARRANGE
            const string regex = @"^a$";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var actuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(3, actuals.Length);
            Assert.AreEqual("Beginning of line or string", actuals[0].Tag.Description);
            Assert.AreEqual("a", actuals[1].Tag.Description);
            Assert.AreEqual("End of line or string", actuals[2].Tag.Description);
        }
        public void AnyDigitInACaptureGroup()
        {
            // ARRANGE
            const string regex = @"(\d)";
            var expression = new Expression(regex, DefaultOffSet, OptionsIgnorePatternWhitespace, OptionsEcmaScript);

            // ACT
            var actuals = expression.GetNodes();

            // ASSERT
            Assert.AreEqual(1, actuals.Length);
            var actual = actuals[0];
            Assert.IsInstanceOfType(actual.Tag, typeof(Group));
            Assert.AreEqual("Any digit", ((Group)actual.Tag).Content.Exp[0].Description);
        }