Browse Source

2005-06-16 Sebastien Pouliot <[email protected]>

	* NamedPermissionSetTest.cs: Added more extensive constructor and 
	default values testing.


svn path=/trunk/mcs/; revision=46090
Sebastien Pouliot 20 years ago
parent
commit
7ed580e238

+ 5 - 0
mcs/class/corlib/Test/System.Security/ChangeLog

@@ -1,3 +1,8 @@
+2005-06-16  Sebastien Pouliot  <[email protected]>
+
+	* NamedPermissionSetTest.cs: Added more extensive constructor and 
+	default values testing.
+
 2005-06-10  Sebastien Pouliot  <[email protected]>
 
 	* PermissionSetTest.cs: Added tests for GetPermission with null and 

+ 108 - 2
mcs/class/corlib/Test/System.Security/NamedPermissionSetTest.cs

@@ -5,7 +5,7 @@
 //	Sebastien Pouliot  <[email protected]>
 //
 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -53,8 +53,114 @@ namespace MonoTests.System.Security {
 		public void ConstructorNameEmpty () 
 		{
 			NamedPermissionSet nps = new NamedPermissionSet ("");
+		}
+
+		[Test]
+		public void ConstructorName ()
+		{
+			NamedPermissionSet nps = new NamedPermissionSet ("name");
+			AssertEquals ("Name", "name", nps.Name);
+			AssertNull ("Description", nps.Description);
+			Assert ("IsUnrestricted", nps.IsUnrestricted ());
+			Assert ("IsEmpty", !nps.IsEmpty ());
+			Assert ("IsReadOnly", !nps.IsReadOnly);
+			Assert ("IsSynchronized", !nps.IsSynchronized);
+			AssertEquals ("Count", 0, nps.Count);
+		}
+
+		[Test]
+		public void ConstructorNameReserved ()
+		{
+			NamedPermissionSet nps = new NamedPermissionSet ("FullTrust");
+			AssertEquals ("Name", "FullTrust", nps.Name);
+			AssertNull ("Description", nps.Description);
+			Assert ("IsUnrestricted", nps.IsUnrestricted ());
+			Assert ("IsEmpty", !nps.IsEmpty ());
+			Assert ("IsReadOnly", !nps.IsReadOnly);
+			Assert ("IsSynchronized", !nps.IsSynchronized);
+			AssertEquals ("Count", 0, nps.Count);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ConstructorNamedPermissionSetNull ()
+		{
+			NamedPermissionSet nullps = null;
+			NamedPermissionSet nps = new NamedPermissionSet (nullps);
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConstructorNameNullPermissionState ()
+		{
+			new NamedPermissionSet (null, PermissionState.None);
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConstructorNameEmptyPermissionState ()
+		{
+			new NamedPermissionSet (String.Empty, PermissionState.None);
 		}
-
+
+		[Test]
+		public void ConstructorNamePermissionStateNone ()
+		{
+			NamedPermissionSet nps = new NamedPermissionSet ("name", PermissionState.None);
+			AssertEquals ("Name", "name", nps.Name);
+			AssertNull ("Description", nps.Description);
+			Assert ("IsUnrestricted", !nps.IsUnrestricted ());
+			Assert ("IsEmpty", nps.IsEmpty ());
+			Assert ("IsReadOnly", !nps.IsReadOnly);
+			Assert ("IsSynchronized", !nps.IsSynchronized);
+			AssertEquals ("Count", 0, nps.Count);
+		}
+
+		[Test]
+		public void ConstructorNamePermissionStateUnrestricted ()
+		{
+			NamedPermissionSet nps = new NamedPermissionSet ("name", PermissionState.Unrestricted);
+			AssertEquals ("Name", "name", nps.Name);
+			AssertNull ("Description", nps.Description);
+			Assert ("IsUnrestricted", nps.IsUnrestricted ());
+			Assert ("IsEmpty", !nps.IsEmpty ());
+			Assert ("IsReadOnly", !nps.IsReadOnly);
+			Assert ("IsSynchronized", !nps.IsSynchronized);
+			AssertEquals ("Count", 0, nps.Count);
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConstructorNameNullPermissionSet ()
+		{
+			new NamedPermissionSet (null, new PermissionSet (PermissionState.None));
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void ConstructorNameEmptyPermissionSet ()
+		{
+			new NamedPermissionSet (String.Empty, new PermissionSet (PermissionState.None));
+		}
+
+		[Test]
+		public void ConstructorNamePermissionSetNull ()
+		{
+			NamedPermissionSet nps = new NamedPermissionSet ("name", null);
+			AssertEquals ("Name", "name", nps.Name);
+			AssertNull ("Description", nps.Description);
+#if NET_2_0
+			Assert ("IsUnrestricted", !nps.IsUnrestricted ());
+			Assert ("IsEmpty", nps.IsEmpty ());
+#else
+			Assert ("IsUnrestricted", nps.IsUnrestricted ());
+			Assert ("IsEmpty", !nps.IsEmpty ());
+#endif
+			Assert ("IsReadOnly", !nps.IsReadOnly);
+			Assert ("IsSynchronized", !nps.IsSynchronized);
+			AssertEquals ("Count", 0, nps.Count);
+		}
+
 		[Test]
 		public void Description () 
 		{