SecurityElement fixed and several methods implemented, added test unit
authorLawrence Pit <lawrence@mono-cvs.ximian.com>
Sat, 27 Apr 2002 10:49:32 +0000 (10:49 -0000)
committerLawrence Pit <lawrence@mono-cvs.ximian.com>
Sat, 27 Apr 2002 10:49:32 +0000 (10:49 -0000)
svn path=/trunk/mcs/; revision=4085

mcs/class/System/Test/System.Net/AllTests.cs
mcs/class/System/Test/System.Net/CookieTest.cs
mcs/class/corlib/System.Security/ChangeLog
mcs/class/corlib/System.Security/SecurityElement.cs
mcs/class/corlib/Test/AllTests.cs
mcs/class/corlib/Test/ChangeLog
mcs/class/corlib/Test/System.Net/AllTests.cs
mcs/class/corlib/Test/System.Net/CookieTest.cs
mcs/class/corlib/Test/System.Security/AllTests.cs [new file with mode: 0644]
mcs/class/corlib/Test/System.Security/ChangeLog [new file with mode: 0644]
mcs/class/corlib/Test/System.Security/SecurityElementTest.cs [new file with mode: 0644]

index 2414ae34fe7e4a6b16005fd255195987de80cd4a..5fb503c46d6966748e893de7baa5b33ec3225ba0 100644 (file)
@@ -14,17 +14,17 @@ namespace MonoTests.System.Net {
         /// </summary>
         public class AllTests : TestCase {
 
-                public AllTests(string name) : base(name) {}
+                public AllTests (string name) : base (name) {}
                 
                 public static ITest Suite { 
                         get 
                         {
-                                TestSuite suite = new TestSuite();
+                                TestSuite suite = new TestSuite ();
                                 suite.AddTest (IPAddressTest.Suite);
                                 suite.AddTest (IPEndPointTest.Suite);
                                 suite.AddTest (CookieTest.Suite);
                                 suite.AddTest (CookieCollectionTest.Suite);
-                                // suite.AddTest (CookieContainerTest.Suite);
+                                suite.AddTest (CookieContainerTest.Suite);
                                return suite;
                         }
                 }
index 6f9110be7fbeaef0125db484848b1f41f2102574..f9f41e9b74ead016757ae2f684135b4ddc09819c 100644 (file)
@@ -71,7 +71,7 @@ public class CookieTest : TestCase
                try {\r
                        c.Name = "xxx\r\n";\r
                        Fail ("#2g");                   \r
-               } catch (CookieException ttt) {\r
+               } catch (CookieException) {\r
                        AssertEquals ("#2h", String.Empty, c.Name);                     \r
                }               \r
                try {\r
index d4ed1abd67e3404591928d6a65271681e66463c4..6e90ebd01649314013061be199202ffd3e05fd44 100755 (executable)
@@ -1,3 +1,7 @@
+2002-04-47  Lawrence Pit <loz@cable.a2000.nl>
+
+       * SecurityElement.cs: fixed bugs, implemented several methods
+
 2002-03-12  Duncan Mak  <duncan@ximian.com>
 
        * SecurityException.cs: Inherit from SystemException, not Exception.
index 375d1f17f67e226ea2afea1f5dc5c6ae87a23266..5fa856b42fb101c20949b4318468c63799065ee0 100755 (executable)
@@ -3,6 +3,7 @@
 //
 // Author:
 //   Miguel de Icaza (miguel@ximian.com)
+//   Lawrence Pit (loz@cable.a2000.nl)
 //
 // (C) Ximian, Inc. http://www.ximian.com
 
@@ -10,55 +11,85 @@ using System.Globalization;
 using System.Collections;
 using System.Text;
 
-namespace System.Security {
-
-       [MonoTODO ("See bottom of the class for missing methods")]
+namespace System.Security 
+{
        [Serializable]
-       public sealed class SecurityElement {
+       public sealed class SecurityElement 
+       {
                string text;
                string tag;
+               Hashtable attributes;
+               ArrayList children;
                
-               public SecurityElement (string tag, string text)
+               // these values are determined by a simple test program against the MS.Net implementation:
+               //      for (int i = 0; i < 256; i++) {
+               //              if (!SecurityElement.IsValidTag ("" + ((char) i))) {
+               //                      System.Console.WriteLine ("TAG: " + i);
+               //              }
+               //      }               
+               // note: this is actually an incorrect implementation of MS, as for example the &
+               // character is not a valid character in tag names.
+               private static char [] invalid_tag_chars = new char [] { ' ', '<', '>' };
+               private static char [] invalid_text_chars = new char [] { '<', '>' };
+               private static char [] invalid_attr_name_chars = new char [] { ' ', '<', '>' };
+               private static char [] invalid_attr_value_chars = new char [] { '"', '<', '>' };
+               private static char [] invalid_chars = new char [] { '<', '>', '"', '\'', '&' };
+               
+               public SecurityElement (string tag) : this (tag, null)
                {
-                       if (tag.IndexOfAny (invalid_chars) != -1)
-                               throw new ArgumentException (Locale.GetText ("Invalid XML string"));
-                       if (text.IndexOfAny (invalid_chars) != -1 ||
-                           tag.IndexOfAny (invalid_chars) != -1)
-                               throw new ArgumentException (Locale.GetText ("Invalid XML string"));
-                       
-                       this.tag = tag;
-                       this.text = text;
                }
-               public SecurityElement (string tag)
+               
+               public SecurityElement (string tag, string text)
                {
-                       if (tag.IndexOfAny (invalid_chars) != -1)
-                               throw new ArgumentException (Locale.GetText ("Invalid XML string"));
-
-                       this.tag = tag;
+                       this.Tag = tag;
+                       this.Text = (text == null) ? String.Empty : text;
                }
-
-               Hashtable attributes;
+               
                public Hashtable Attributes {
                        get {
-                               return attributes;
+                               if (attributes == null) 
+                                       return null;
+                                       
+                               Hashtable result = new Hashtable ();
+                               IDictionaryEnumerator e = attributes.GetEnumerator ();
+                               while (e.MoveNext ())
+                                       result.Add (e.Key, e.Value);
+                               return result;
                        }
 
-                       set {
-                               attributes = value;
+                       set {                           
+                               if (value == null || value.Count == 0) {
+                                       attributes = null;
+                                       return;
+                               }
+                               
+                               Hashtable result = new Hashtable ();
+                               IDictionaryEnumerator e = value.GetEnumerator ();
+                               while (e.MoveNext ()) {
+                                       string key = (string) e.Key;
+                                       string val = (string) e.Value;
+                                       if (IsValidAttributeName (key))         
+                                               throw new ArgumentException (Locale.GetText ("Invalid XML string") + ": " + key);
+                                       if (IsValidAttributeValue (val))                
+                                               throw new ArgumentException (Locale.GetText ("Invalid XML string") + ": " + key);
+                                       result.Add (key, val);
+                               }
+                               attributes = result;
                        }
                }
 
-               ArrayList children;
                public ArrayList Children {
                        get {
                                return children;
                        }
 
                        set {
-                               if (value != null){
-                                       foreach (object o in children){
+                               if (value != null) {
+                                       foreach (object o in value) {
                                                if (o == null)
                                                        throw new ArgumentNullException ();
+                                               // shouldn't we also throw an exception 
+                                               // when o isn't an instance of SecurityElement?
                                        }
                                }
                                children = value;
@@ -72,8 +103,8 @@ namespace System.Security {
                        set {
                                if (value == null)
                                        throw new ArgumentNullException ();
-                               if (tag.IndexOfAny (invalid_chars) != -1)
-                                       throw new ArgumentException (Locale.GetText ("Invalid XML string"));
+                               if (!IsValidTag (value))
+                                       throw new ArgumentException (Locale.GetText ("Invalid XML string") + ": " + value);
                                tag = value;
                        }
                }
@@ -84,9 +115,8 @@ namespace System.Security {
                        }
 
                        set {
-                               if (value != null && (value.IndexOfAny (invalid_chars) != -1))
-                                       throw new ArgumentException (Locale.GetText ("Invalid XML string"));
-                               
+                               if (!IsValidText (value))
+                                       throw new ArgumentException (Locale.GetText ("Invalid XML string") + ": " + text);                              
                                text = value;
                        }
                }
@@ -103,11 +133,11 @@ namespace System.Security {
                        // The hashtable will throw ArgumentException if name is already there
                        //
 
-                       if (name.IndexOfAny (invalid_chars) != -1)
-                               throw new ArgumentException (Locale.GetText ("Invalid XML string"));
+                       if (!IsValidAttributeName (name))
+                               throw new ArgumentException (Locale.GetText ("Invalid XML string") + ": " + name);
 
-                       if (value.IndexOfAny (invalid_chars) != -1)
-                               throw new ArgumentException (Locale.GetText ("Invalid XML string"));
+                       if (!IsValidAttributeValue (value))
+                               throw new ArgumentException (Locale.GetText ("Invalid XML string") + ": " + value);
                        
                        attributes.Add (name, value);
                }
@@ -138,18 +168,48 @@ namespace System.Security {
                {
                        if (other == null)
                                return false;
+                               
+                       if (this == other)
+                               return true;
 
-                       if (text != other.text)
+                       if (this.text != other.text)
                                return false;
 
-                       if (tag != other.tag)
+                       if (this.tag != other.tag)
+                               return false;
+
+                       if (this.attributes == null && other.attributes != null && other.attributes.Count != 0)
+                               return false;
+                               
+                       if (other.attributes == null && this.attributes != null && this.attributes.Count != 0)
                                return false;
 
-                       throw new Exception ("IMPLEMENT ME: Compare attributes and children");
+                       if (this.attributes != null && other.attributes != null) {
+                               if (this.attributes.Count != other.attributes.Count) 
+                                       return false;
+                               IDictionaryEnumerator e = attributes.GetEnumerator ();
+                               while (e.MoveNext ()) 
+                                       if (other.attributes [e.Key] != e.Value)
+                                               return false;
+                       }
+                       
+                       if (this.children == null && other.children != null & other.children.Count != 0)
+                               return false;
+                                       
+                       if (other.children == null && this.children != null & this.children.Count != 0)
+                               return false;
+                               
+                       if (this.children != null && other.children != null) {
+                               if (this.children.Count != other.children.Count)
+                                       return false;
+                               for (int i = 0; i < this.children.Count; i++) 
+                                       if (!((SecurityElement) this.children [i]).Equal ((SecurityElement) other.children [i]))
+                                               return false;
+                       }
+                       
+                       return true;
                }
 
-               static char [] invalid_chars = new char [] { '<', '>', '"', '\'', '&' };
-               
                public static string Escape (string str)
                {
                        StringBuilder sb;
@@ -160,10 +220,10 @@ namespace System.Security {
                        sb = new StringBuilder ();
                        int len = str.Length;
                        
-                       for (int i = 0; i < len; i++){
+                       for (int i = 0; i < len; i++) {
                                char c = str [i];
 
-                               switch (c){
+                               switch (c) {
                                case '<':  sb.Append ("&lt;"); break;
                                case '>':  sb.Append ("&gt;"); break;
                                case '"':  sb.Append ("&quot;"); break;
@@ -176,31 +236,103 @@ namespace System.Security {
                        return sb.ToString ();
                }
 
-               public static bool IsInvalidAttributeName (string name)
+               public static bool IsValidAttributeName (string name)
                {
-                       return name.IndexOfAny (invalid_chars) != -1;
+                       return name != null && name.IndexOfAny (invalid_attr_name_chars) == -1;
                }
 
-               public static bool IsInvalidAttributeValue (string value)
+               public static bool IsValidAttributeValue (string value)
                {
-                       return value.IndexOfAny (invalid_chars) != -1;
+                       return value != null && value.IndexOfAny (invalid_attr_value_chars) == -1;
                }
 
-               public static bool IsInvalidTag (string value)
+               public static bool IsValidTag (string value)
                {
-                       return value.IndexOfAny (invalid_chars) != -1;
+                       return value != null && value.IndexOfAny (invalid_tag_chars) == -1;
                }
 
-               public static bool IsInvalidText (string value)
+               public static bool IsValidText (string value)
                {
-                       return value.IndexOfAny (invalid_chars) != -1;
+                       return value != null && value.IndexOfAny (invalid_text_chars) == -1;
                }
 
-               //
-               // TODO:
-               //
-               // SearchForChildByTag
-               // SearchForTextOfTag
-               // ToString
+               public SecurityElement SearchForChildByTag (string tag) 
+               {
+                       if (tag == null)
+                               throw new ArgumentNullException ("tag");
+                               
+                       if (this.children == null)
+                               return null;
+                               
+                       for (int i = 0; i < children.Count; i++) {
+                               SecurityElement elem = (SecurityElement) children [i];
+                               if (elem.tag == tag)
+                                       return elem;
+                       }
+                       return null;
+               }                       
+
+               public string SearchForTextOfTag (string tag) 
+               {
+                       if (tag == null)
+                               throw new ArgumentNullException ("tag");
+                               
+                       if (this.tag == tag)
+                               return this.text;
+                               
+                       if (this.children == null)
+                               return null;
+                       
+                       for (int i = 0; i < children.Count; i++) {
+                               string result = ((SecurityElement) children [i]).SearchForTextOfTag (tag);
+                               if (result != null) 
+                                       return result;
+                       }
+
+                       return null;                    
+               }
+               
+               public override string ToString ()
+               {
+                       StringBuilder s = new StringBuilder ();
+                       ToXml (ref s, 0);
+                       return s.ToString ();
+               }
+               
+               private void ToXml(ref StringBuilder s, int level)
+               {
+                       s.Append (' ', level << 2);
+                       s.Append ("<");
+                       s.Append (tag);
+                       
+                       if (attributes != null) {
+                               IDictionaryEnumerator e = attributes.GetEnumerator ();                          
+                               while (e.MoveNext ()) {
+                                       s.Append (" ")
+                                        .Append (e.Key)
+                                        .Append ("=\"")
+                                        .Append (e.Value)
+                                        .Append ("\"");
+                               }
+                       }
+                       
+                       if ((text == null || text == String.Empty) && 
+                           (children == null || children.Count == 0))
+                               s.Append ("/>");
+                       else {
+                               s.Append (">").Append (text);
+                               if (children != null) {
+                                       for (int i = 0; i < children.Count; i++) {
+                                               s.Append (Environment.NewLine);
+                                               ((SecurityElement) children [i]).ToXml (ref s, level + 1);
+                                       }
+                               }
+                               s.Append (Environment.NewLine)
+                                .Append (' ', level << 2)
+                                .Append ("</")
+                                .Append (tag)
+                                .Append (">");
+                       }
+               }
        }
 }
index a5c11a2f96c695cf76e0ac6bc786443b5c8d09f7..59072cba2d994625130fe30bf2fcb8bb03d6bf06 100644 (file)
@@ -24,6 +24,7 @@ namespace MonoTests {
                                 TestSuite suite =  new TestSuite();\r
                                 suite.AddTest(System.AllTests.Suite);\r
                                 suite.AddTest(System.Collections.AllTests.Suite);\r
+                                suite.AddTest(System.Security.AllTests.Suite);\r
                                 suite.AddTest(System.Security.Cryptography.AllTests.Suite);\r
                                 suite.AddTest(System.IO.AllTests.Suite);\r
                                 suite.AddTest(System.Net.AllTests.Suite);\r
index 8d52a940566d00d41fa720d9435be9df78d48cc3..47b566f65f9d7172ec26eb23580a39275db8e7bb 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-27  Lawrence Pit <loz@cable.a2000.nl>\r
+\r
+       * System.Security/: added directory\r
+       * AllTests.cs: added Syste,Security suite.\r
+\r
 2002-04-15  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * System.Net/: added directory.
index 2414ae34fe7e4a6b16005fd255195987de80cd4a..5fb503c46d6966748e893de7baa5b33ec3225ba0 100644 (file)
@@ -14,17 +14,17 @@ namespace MonoTests.System.Net {
         /// </summary>
         public class AllTests : TestCase {
 
-                public AllTests(string name) : base(name) {}
+                public AllTests (string name) : base (name) {}
                 
                 public static ITest Suite { 
                         get 
                         {
-                                TestSuite suite = new TestSuite();
+                                TestSuite suite = new TestSuite ();
                                 suite.AddTest (IPAddressTest.Suite);
                                 suite.AddTest (IPEndPointTest.Suite);
                                 suite.AddTest (CookieTest.Suite);
                                 suite.AddTest (CookieCollectionTest.Suite);
-                                // suite.AddTest (CookieContainerTest.Suite);
+                                suite.AddTest (CookieContainerTest.Suite);
                                return suite;
                         }
                 }
index 6f9110be7fbeaef0125db484848b1f41f2102574..f9f41e9b74ead016757ae2f684135b4ddc09819c 100644 (file)
@@ -71,7 +71,7 @@ public class CookieTest : TestCase
                try {\r
                        c.Name = "xxx\r\n";\r
                        Fail ("#2g");                   \r
-               } catch (CookieException ttt) {\r
+               } catch (CookieException) {\r
                        AssertEquals ("#2h", String.Empty, c.Name);                     \r
                }               \r
                try {\r
diff --git a/mcs/class/corlib/Test/System.Security/AllTests.cs b/mcs/class/corlib/Test/System.Security/AllTests.cs
new file mode 100644 (file)
index 0000000..5f32c30
--- /dev/null
@@ -0,0 +1,27 @@
+//
+// TestSuite.System.Security.AllSecurityTests.cs
+//
+// Lawrence Pit <loz@cable.a2000.nl>
+// 
+
+using System;
+using NUnit.Framework;
+
+namespace MonoTests.System.Security {
+        /// <summary>
+        ///   Combines all available unit tests into one test suite.
+        /// </summary>
+        public class AllTests : TestCase {
+
+                public AllTests (string name) : base (name) {}
+                
+                public static ITest Suite { 
+                        get {
+                                TestSuite suite = new TestSuite ();
+                                suite.AddTest (SecurityElementTest.Suite);
+                               return suite;
+                        }
+                }
+        }
+}
+
diff --git a/mcs/class/corlib/Test/System.Security/ChangeLog b/mcs/class/corlib/Test/System.Security/ChangeLog
new file mode 100644 (file)
index 0000000..bc284db
--- /dev/null
@@ -0,0 +1,6 @@
+2002-04-27  Lawrence Pit <loz@cable.a2000.nl>
+
+       * ChangeLog: added
+       * AllTests.cs: added
+       * SecurityElementTest.cs: added
+
diff --git a/mcs/class/corlib/Test/System.Security/SecurityElementTest.cs b/mcs/class/corlib/Test/System.Security/SecurityElementTest.cs
new file mode 100644 (file)
index 0000000..5902501
--- /dev/null
@@ -0,0 +1,218 @@
+//\r
+// SecurityElementTest.cs - NUnit Test Cases for System.Security.SecurityElement\r
+//\r
+// Author:\r
+//   Lawrence Pit (loz@cable.a2000.nl)\r
+//\r
+\r
+using NUnit.Framework;\r
+using System;\r
+using System.Collections;\r
+using System.Security;\r
+\r
+namespace MonoTests.System.Security\r
+{\r
+\r
+public class SecurityElementTest : TestCase\r
+{\r
+       SecurityElement elem;\r
+       \r
+        public SecurityElementTest () :\r
+                base ("[MonoTests.System.Security.SecurityElementTest]") {}\r
+\r
+        public SecurityElementTest (string name) : base (name) {}\r
+\r
+        protected override void SetUp () \r
+        {\r
+               elem = CreateElement ();\r
+       }\r
+\r
+        protected override void TearDown () {}\r
+        \r
+        private SecurityElement CreateElement ()\r
+        {\r
+               SecurityElement elem = new SecurityElement ("IPermission");\r
+               elem.AddAttribute ("class", "System");\r
+               elem.AddAttribute ("version", "1");\r
+               \r
+               SecurityElement child = new SecurityElement ("ConnectAccess");          \r
+               elem.AddChild (child);\r
+               \r
+               SecurityElement grandchild = new SecurityElement ("ENDPOINT", "some text");             \r
+               grandchild.AddAttribute ("transport", "All");\r
+               grandchild.AddAttribute ("host", "localhost");\r
+               grandchild.AddAttribute ("port", "8080");\r
+               child.AddChild (grandchild);\r
+\r
+               SecurityElement grandchild2 = new SecurityElement ("ENDPOINT");         \r
+               grandchild2.AddAttribute ("transport", "Tcp");\r
+               grandchild2.AddAttribute ("host", "www.ximian.com");\r
+               grandchild2.AddAttribute ("port", "All");\r
+               child.AddChild (grandchild2);           \r
+               \r
+               return elem;            \r
+       }\r
+\r
+        public static ITest Suite\r
+        {\r
+                get {\r
+                        return new TestSuite (typeof (SecurityElementTest));\r
+                }\r
+        }\r
+\r
+        public void TestConstructors ()\r
+        {\r
+               \r
+       }\r
+       \r
+       public void TestAddAttribute ()\r
+       {\r
+               try {\r
+                       elem.AddAttribute (null, "valid");\r
+                       Fail ("#1");\r
+               } catch (ArgumentNullException) { }\r
+               try {\r
+                       elem.AddAttribute ("valid", null);\r
+                       Fail ("#2");\r
+               } catch (ArgumentNullException) { }\r
+               try {\r
+                       elem.AddAttribute ("<invalid>", "valid");\r
+                       Fail ("#3");\r
+               } catch (ArgumentException) { }\r
+               try {\r
+                       elem.AddAttribute ("valid", "invalid\"");\r
+                       Fail ("#4");\r
+               } catch (ArgumentException) { }\r
+               try {\r
+                       elem.AddAttribute ("valid", "valid\'");                 \r
+               } catch (ArgumentException) { Fail ("#5"); }\r
+               try {                   \r
+                       elem.AddAttribute ("valid", "valid&");\r
+                       Fail ("#6");\r
+                       // in xml world this is actually not considered valid\r
+                       // but it is by MS.Net\r
+               } catch (ArgumentException) { }\r
+               try {\r
+                       elem.AddAttribute ("valid", "<invalid>");\r
+                       Fail ("#7"); \r
+               } catch (ArgumentException) { }\r
+       }\r
+       \r
+       public void TestAttributes ()\r
+       {\r
+               Hashtable h = elem.Attributes;\r
+               \r
+               /*\r
+               // this will result in an InvalidCastException on MS.Net\r
+               // I have no clue why\r
+               \r
+               h.Add ("<invalid>", "valid");\r
+               try {\r
+                       elem.Attributes = h;\r
+                       Fail ("#1");\r
+               } catch (ArgumentException) { }\r
+                */\r
+                \r
+               h = elem.Attributes;\r
+               h.Add ("valid", "\"invalid\"");\r
+               try {\r
+                       elem.Attributes = h;\r
+                       Fail ("#2");\r
+               } catch (ArgumentException) { }\r
+               \r
+               h = elem.Attributes;\r
+               h.Add ("foo", "bar");\r
+               Assert ("#3", elem.Attributes.Count != h.Count);\r
+               \r
+               elem.Attributes = h;\r
+               Assert ("#4", elem.Attribute ("foo") != null);\r
+       }\r
+       \r
+       public void TestEqual ()\r
+       {\r
+               SecurityElement elem2 = CreateElement ();\r
+               Assert ("#1", elem.Equal (elem2));\r
+               SecurityElement child = (SecurityElement) elem2.Children [0];\r
+               child = (SecurityElement) child.Children [1];\r
+               child.Text = "some text";\r
+               Assert ("#1", !elem.Equal (elem2));\r
+       }\r
+       \r
+       public void TestEscape ()\r
+       {\r
+               AssertEquals ("#1", SecurityElement.Escape ("foo<>\"'& bar"), "foo&lt;&gt;&quot;&apos;&amp; bar");\r
+       }\r
+       \r
+       public void TestIsValidAttributeName ()\r
+       {\r
+               Assert ("#1", !SecurityElement.IsValidAttributeName ("x x")); \r
+               Assert ("#2", !SecurityElement.IsValidAttributeName ("x<x")); \r
+               Assert ("#3", !SecurityElement.IsValidAttributeName ("x>x"));\r
+               Assert ("#4", SecurityElement.IsValidAttributeName ("x\"x"));\r
+               Assert ("#5", SecurityElement.IsValidAttributeName ("x'x"));\r
+               Assert ("#6", SecurityElement.IsValidAttributeName ("x&x"));                    \r
+       }\r
+\r
+       public void TestIsValidAttributeValue ()\r
+       {\r
+               Assert ("#1", SecurityElement.IsValidAttributeValue ("x x")); \r
+               Assert ("#2", !SecurityElement.IsValidAttributeValue ("x<x")); \r
+               Assert ("#3", !SecurityElement.IsValidAttributeValue ("x>x"));\r
+               Assert ("#4", !SecurityElement.IsValidAttributeValue ("x\"x"));\r
+               Assert ("#5", SecurityElement.IsValidAttributeValue ("x'x"));\r
+               Assert ("#6", SecurityElement.IsValidAttributeValue ("x&x"));           \r
+       }\r
+\r
+       public void TestIsValidTag ()\r
+       {\r
+               Assert ("#1", !SecurityElement.IsValidTag ("x x")); \r
+               Assert ("#2", !SecurityElement.IsValidTag ("x<x")); \r
+               Assert ("#3", !SecurityElement.IsValidTag ("x>x"));\r
+               Assert ("#4", SecurityElement.IsValidTag ("x\"x"));\r
+               Assert ("#5", SecurityElement.IsValidTag ("x'x"));\r
+               Assert ("#6", SecurityElement.IsValidTag ("x&x"));\r
+       }\r
+\r
+       public void TestIsValidText ()\r
+       {\r
+               Assert ("#1", SecurityElement.IsValidText ("x x")); \r
+               Assert ("#2", !SecurityElement.IsValidText ("x<x")); \r
+               Assert ("#3", !SecurityElement.IsValidText ("x>x"));\r
+               Assert ("#4", SecurityElement.IsValidText ("x\"x"));\r
+               Assert ("#5", SecurityElement.IsValidText ("x'x"));\r
+               Assert ("#6", SecurityElement.IsValidText ("x&x"));\r
+       }\r
+       \r
+       public void TestSearchForChildByTag ()\r
+       {\r
+               SecurityElement child = null;\r
+               try {\r
+                       child = elem.SearchForChildByTag (null);\r
+                       Fail ("#1 should have thrown an ArgumentNullException");\r
+               } catch (ArgumentNullException) { }\r
+\r
+               child = elem.SearchForChildByTag ("doesnotexist");\r
+               AssertEquals ("#2", child, null);\r
+               \r
+               child = elem.SearchForChildByTag ("ENDPOINT");\r
+               AssertEquals ("#3", child, null);\r
+               \r
+               child = (SecurityElement) elem.Children [0];\r
+               child = child.SearchForChildByTag ("ENDPOINT");\r
+               AssertEquals ("#4", child.Attribute ("transport"), "All");\r
+       }\r
+       \r
+       public void TestSearchForTextOfTag ()\r
+       {\r
+               try {\r
+                       string t1 = elem.SearchForTextOfTag (null);\r
+                       Fail ("#1 should have thrown an ArgumentNullException");\r
+               } catch (ArgumentNullException) { }\r
+               \r
+               string t2 = elem.SearchForTextOfTag ("ENDPOINT");\r
+               AssertEquals ("#2", t2, "some text");\r
+       }\r
+}\r
+\r
+}\r
+\r