Пример #1
0
        public void HtmlEncodeFormatString()
        {
            string formatString = "<script>alert ('{0}');</script>";
            var    bf           = new PokerBoundField();

            Assert.IsTrue(bf.HtmlEncodeFormatString, "#A1-2");
            Assert.IsTrue(bf.HtmlEncode, "#A1-2");
            Assert.IsTrue(bf.DoSupportsHtmlEncode, "#A1-3");

            bf.DataFormatString = formatString;
#if NET_4_0
            Assert.AreEqual("&lt;script&gt;alert (&#39;&lt;test&gt;&#39;);&lt;/script&gt;", bf.DoFormatDataValue("<test>", true), "#A2");
#else
            Assert.AreEqual("&lt;script&gt;alert ('&lt;test&gt;');&lt;/script&gt;", bf.DoFormatDataValue("<test>", true), "#A2");
#endif
            Assert.AreEqual(String.Format(formatString, "<test>"), bf.DoFormatDataValue("<test>", false), "#A3");

            bf.HtmlEncodeFormatString = false;
            Assert.AreEqual("<script>alert ('&lt;test&gt;');</script>", bf.DoFormatDataValue("<test>", true), "#A4");

            var ec = new EncodingTest();
            bf.HtmlEncodeFormatString = true;
#if NET_4_0
            Assert.AreEqual("&lt;script&gt;alert (&#39;&lt;EncodingTest&gt;&amp;&#39;);&lt;/script&gt;", bf.DoFormatDataValue(ec, true), "#A4");
#else
            Assert.AreEqual("&lt;script&gt;alert ('&lt;EncodingTest&gt;&amp;');&lt;/script&gt;", bf.DoFormatDataValue(ec, true), "#A4");
#endif
        }
Пример #2
0
        public void BoundField_FormatDataValue()
        {
            string          result;
            PokerBoundField bf = new PokerBoundField();

            bf.NullDisplayText = "NullDisplayText";
            result             = bf.DoFormatDataValue(null, false);
            Assert.AreEqual("NullDisplayText", result, "FormatDataValueNullDataValue");

            result = bf.DoFormatDataValue("test", true);
            Assert.AreEqual("test", result, "FormatDataValueTextDataValue");

            result = bf.DoFormatDataValue("", true);
            Assert.AreEqual("NullDisplayText", result, "FormatEmptyDataValue");

            bf.DataFormatString = "-{0,8:G}-";
            result = bf.DoFormatDataValue(10, false);
            Assert.AreEqual("-      10-", result, "FormatDataValueWithFormat");
        }
		public void BoundField_FormatDataValue () {
			string result;
			PokerBoundField bf = new PokerBoundField ();

			bf.NullDisplayText = "NullDisplayText";
			result = bf.DoFormatDataValue (null, false);
			Assert.AreEqual ("NullDisplayText", result, "FormatDataValueNullDataValue");

			result = bf.DoFormatDataValue ("test", true);
			Assert.AreEqual ("test", result, "FormatDataValueTextDataValue");

			result = bf.DoFormatDataValue ("", true);
			Assert.AreEqual ("NullDisplayText", result, "FormatEmptyDataValue");

			bf.DataFormatString = "-{0,8:G}-";
			result = bf.DoFormatDataValue (10, false);
			Assert.AreEqual ("-      10-", result, "FormatDataValueWithFormat");
		}
Пример #4
0
		public void HtmlEncodeFormatString ()
		{
			string formatString = "<script>alert ('{0}');</script>"; 
			var bf = new PokerBoundField ();

			Assert.IsTrue (bf.HtmlEncodeFormatString, "#A1-2");
			Assert.IsTrue (bf.HtmlEncode, "#A1-2");
			Assert.IsTrue (bf.DoSupportsHtmlEncode, "#A1-3");

			bf.DataFormatString = formatString;
#if NET_4_0
			Assert.AreEqual ("&lt;script&gt;alert (&#39;&lt;test&gt;&#39;);&lt;/script&gt;", bf.DoFormatDataValue ("<test>", true), "#A2");
#else
			Assert.AreEqual ("&lt;script&gt;alert ('&lt;test&gt;');&lt;/script&gt;", bf.DoFormatDataValue ("<test>", true), "#A2");
#endif
			Assert.AreEqual (String.Format (formatString, "<test>"), bf.DoFormatDataValue ("<test>", false), "#A3");

			bf.HtmlEncodeFormatString = false;
			Assert.AreEqual ("<script>alert ('&lt;test&gt;');</script>", bf.DoFormatDataValue ("<test>", true), "#A4");

			var ec = new EncodingTest ();
			bf.HtmlEncodeFormatString = true;
#if NET_4_0
			Assert.AreEqual ("&lt;script&gt;alert (&#39;&lt;EncodingTest&gt;&amp;&#39;);&lt;/script&gt;", bf.DoFormatDataValue (ec, true), "#A4");
#else
			Assert.AreEqual ("&lt;script&gt;alert ('&lt;EncodingTest&gt;&amp;');&lt;/script&gt;", bf.DoFormatDataValue (ec, true), "#A4");
#endif
		}