public void GetMatchesOf_A_3_ForAAABBBReturnsAAA()
        {
            int index = 0;
             int length = 3;
             GreedyRepeatExpression<char> expression = new GreedyRepeatExpression<char> (m_A, length);

             var list = AAABBB;
             var matches = expression.GetMatches (list, index).ToList ();

             Assert.AreEqual (1, matches.Count (), "Count");
             foreach (var match in matches)
             {
            Assert.AreEqual (index, match.Index, "match.Index");
            Assert.AreEqual (length, match.Length, "match.Length");
            Assert.IsTrue (match.Success, "match.Success");
            Assert.AreEqual (length, match.Items.Count, "match.Items.Count");
            for (int i = 0; i < length; i++)
            {
               Assert.AreEqual (list[index + i], match.Items [i], "match.Items [" + i + "]");
            }
             }
        }
        public void GetMatchesOf_Any_2_ForDigetsStartingAt5Returns56()
        {
            int index = 5;
             GreedyRepeatExpression<char> expression = new GreedyRepeatExpression<char> (m_any, 2);
             int length = 2;

             var list = DigetsList;
             var matches = expression.GetMatches (list, index).ToList ();

             Assert.AreEqual (1, matches.Count (), "Count");
             foreach (var match in matches)
             {
            Assert.AreEqual (index, match.Index, "match.Index");
            Assert.AreEqual (length, match.Length, "match.Length");
            Assert.IsTrue (match.Success, "match.Success");
            Assert.AreEqual (length, match.Items.Count, "match.Items.Count");
            for (int i = 0; i < length; i++)
            {
               Assert.AreEqual (list[index + i], match.Items [i], "match.Items [" + i + "]");
            }
             }
        }
        public void GetMatchesOfDigits_Any_4_8()
        {
            var expression = new GreedyRepeatExpression<char> (m_any, 4, 8);

             string [] expectedValues =
            new [] {"0123", "01234", "012345", "0123456", "01234567"}
               .Reverse ()
               .ToArray ();

             int index = 0;
             var list = DigetsList;

             var matches = expression.GetMatches (list, index).ToList ();

             Assert.AreEqual (expectedValues.Length, matches.Count (), "Count");
             for (int i = 0; i < expectedValues.Length; i++)
             {
            var match = matches [i];
            var expected = expectedValues [i];
            Assert.AreEqual (index, match.Index, "match.Index at " + i);
            Assert.AreEqual (expected.Length, match.Length, "match.Length at " + i);
            Assert.IsTrue (match.Success, "match.Success at " + i);
            Assert.AreEqual (expected.Length, match.Items.Count, "match.Items.Count at " + i);
            Assert.AreEqual (expected, new string (match.Items.ToArray ()), "Value at " + i);
             }
        }
        public void GetMatchesOf_AAorABorBB_1_2_ForAAABBB()
        {
            int index = 0;
             GreedyRepeatExpression<char> expression =
            new GreedyRepeatExpression<char> (
               new AlternationExpression<char> (
                  new ListExpression<char>(m_A, m_A),
                  new ListExpression<char>(m_A, m_B),
                  new ListExpression<char>(m_B, m_B)),
               1, 2);

             string [] expectedValues =
            new [] {"AA", "AAAB"}
               .Reverse ()
               .ToArray ();
             var list = AAABBB;

             var matches = expression.GetMatches (list, index).ToList ();

             Assert.AreEqual (expectedValues.Length, matches.Count (), "Count");
             for (int i = 0; i < expectedValues.Length; i++)
             {
            var match = matches [i];
            var expected = expectedValues [i];
            Assert.AreEqual (index, match.Index, "match.Index at " + i);
            Assert.AreEqual (expected.Length, match.Length, "match.Length at " + i);
            Assert.IsTrue (match.Success, "match.Success at " + i);
            Assert.AreEqual (expected.Length, match.Items.Count, "match.Items.Count at " + i);

            Assert.AreEqual (expected, new string (match.Items.ToArray ()), "Value at " + i);
             }
        }
        public void GetMatchesFindsOneMatchForA()
        {
            GreedyRepeatExpression<char> expression = new GreedyRepeatExpression<char> (m_A);

             string [] expectedValues = new [] {"A", ""};
             int index = 0;
             var list = AList;
             var matches = expression.GetMatches (list, index).ToList ();

             Assert.AreEqual (expectedValues.Length, matches.Count (), "Count");

             for (int i = 0; i < expectedValues.Length; i++)
             {
            var match = matches [i];
            var expected = expectedValues [i];
            Assert.AreEqual (index, match.Index, "match.Index");
            Assert.AreEqual (expected.Length, match.Length, "match.Length");
            Assert.IsTrue (match.Success, "match.Success");
            Assert.AreEqual (expected.Length, match.Items.Count, "match.Items.Count");
            Assert.AreEqual (expected, new string (match.Items.ToArray ()), "match.Items");
             }
        }