Пример #1
0
        public void RewriteNiceHrefHtmlIsValid()
        {
            String testString = "<a href=\"/something/blah.aspx\">Link Name</a>" + "      </html>";

            Byte[] bytes = UTF8Encoding.UTF8.GetBytes(testString);
            MemoryStream stream = new MemoryStream();
            stream.Write(bytes, 0, bytes.Length);

            RegexFilter testFilter = new RegexFilter(stream, tokenName, tokenValue);
            testFilter.Write(bytes, 0, bytes.Length);

            String responseHtml = testFilter.GetResponseHtml.ToString();

            Assert.AreNotEqual(testString, responseHtml,
                           "responseHtml was not modified by the filter.  It is still:  {0}",
                           responseHtml);
        }
Пример #2
0
        public void RewriteFormEndTagIsValid()
        {
            String testString = "</form>" + "      </html>";

            Byte[] bytes = UTF8Encoding.UTF8.GetBytes(testString);
            MemoryStream stream = new MemoryStream();
            stream.Write(bytes, 0, bytes.Length);

            RegexFilter testFilter = new RegexFilter(stream, tokenName, tokenValue);
            testFilter.Write(bytes, 0, bytes.Length);

            String responseHtml = testFilter.GetResponseHtml.ToString();

            // strings must not be the same, else that means no filtering happened
            Assert.AreNotEqual(testString, responseHtml,
                           "responseHtml was not modified by the filter.  It is still:  {0}",
                           responseHtml);
        }
        public void RewriteHrefHtmlWithInconsistentSpaces()
        {
            String testString = "<a  href    =   \"/something/blah.aspx\">Link Name</a>" + "      </html>";

            Byte[]       bytes  = UTF8Encoding.UTF8.GetBytes(testString);
            MemoryStream stream = new MemoryStream();

            stream.Write(bytes, 0, bytes.Length);

            RegexFilter testFilter = new RegexFilter(stream, tokenName, tokenValue);

            testFilter.Write(bytes, 0, bytes.Length);

            String responseHtml = testFilter.GetResponseHtml.ToString();

            Assert.AreNotEqual(testString, responseHtml,
                               "responseHtml was not modified by the filter.  It is still:  {0}",
                               responseHtml);
        }
        public void RewriteFormEndTagIsValid()
        {
            String testString = "</form>" + "      </html>";

            Byte[]       bytes  = UTF8Encoding.UTF8.GetBytes(testString);
            MemoryStream stream = new MemoryStream();

            stream.Write(bytes, 0, bytes.Length);

            RegexFilter testFilter = new RegexFilter(stream, tokenName, tokenValue);

            testFilter.Write(bytes, 0, bytes.Length);

            String responseHtml = testFilter.GetResponseHtml.ToString();

            // strings must not be the same, else that means no filtering happened
            Assert.AreNotEqual(testString, responseHtml,
                               "responseHtml was not modified by the filter.  It is still:  {0}",
                               responseHtml);
        }