Exemple #1
0
		public void EscapeSequentialDashes ()
		{
			XComment c;

			c = new XComment ("<--foo-->");
			Assert.AreEqual ("<--foo-->", c.Value, "#1");
			// bug #23318
			// Unlike XmlWriter.WriteComment(), XComment.ToString() seems to accept "--" in the value.
			Assert.AreEqual ("<!--<- -foo- ->-->", c.ToString (), "#2");
			// make sure if it can be read...
			XmlReader.Create (new StringReader (c.ToString ())).Read ();

			// The last '-' causes some glitch...
			c = new XComment ("--foo--");
			Assert.AreEqual ("--foo--", c.Value, "#3");
			Assert.AreEqual ("<!--- -foo- &#2D;-->", c.ToString (), "#4");
			XmlReader.Create (new StringReader (c.ToString ())).Read ();

			// What if <!-- appears in the value?
			c = new XComment ("<!--foo-->");
			Assert.AreEqual ("<!--foo-->", c.Value, "#5");
			Assert.AreEqual ("<!--<!- -foo- ->-->", c.ToString (), "#6");
			XmlReader.Create (new StringReader (c.ToString ())).Read ();
		}
 //[Variation(Priority = 3, Desc = "XComment - empty")]
 public void CreateXComment2()
 {
     var comment = new XComment("");
     TestLog.Compare(comment != null, "pi != null");
     TestLog.Compare(comment.NodeType, XmlNodeType.Comment, "NodeType");
     TestLog.Compare(comment.Value, "", "Value");
     TestLog.Compare(comment.Document == null, "Document");
     TestLog.Compare(comment.Parent == null, "Parent");
     TestLog.Compare(comment.ToString(SaveOptions.DisableFormatting), @"<!---->", "Xml");
 }