2005-10-24 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 25 Oct 2005 01:04:26 +0000 (01:04 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 25 Oct 2005 01:04:26 +0000 (01:04 -0000)
* CodeGeneratorOptionsCas.cs: New. CAS unit tests.
* CodeGeneratorOptionsTest.cs: New. Unit tests.
* CodeParserCas.cs: New. CAS unit tests.
* CompilerErrorCas.cs: New. CAS unit tests.
* CompilerErrorCollectionCas.cs: New. CAS unit tests.
* CompilerInfoCas.cs: New. CAS unit tests.
* CompilerParametersCas.cs: New. CAS unit tests.
* CompilerResultsCas.cs: New. CAS unit tests.
* GeneratedCodeAttributeCas.cs: New. CAS unit tests.
* GeneratedCodeAttributeTest.cs: New. Unit tests.
* IndentedTextWriterCas.cs: New. CAS unit tests.

svn path=/trunk/mcs/; revision=52160

12 files changed:
mcs/class/System/Test/System.CodeDom.Compiler/ChangeLog
mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorOptionsCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorOptionsTest.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/CodeParserCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/CompilerErrorCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/CompilerErrorCollectionCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/CompilerInfoCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/CompilerParametersCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/CompilerResultsCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/GeneratedCodeAttributeCas.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/GeneratedCodeAttributeTest.cs [new file with mode: 0644]
mcs/class/System/Test/System.CodeDom.Compiler/IndentedTextWriterCas.cs [new file with mode: 0644]

index 4ebd0feaa3b0a730c13fa1031d538c889209e120..a46e9b0b62a5838577fdd869485c293ec6ae3d53 100644 (file)
@@ -1,3 +1,17 @@
+2005-10-24  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CodeGeneratorOptionsCas.cs: New. CAS unit tests.
+       * CodeGeneratorOptionsTest.cs: New. Unit tests.
+       * CodeParserCas.cs: New. CAS unit tests.
+       * CompilerErrorCas.cs: New. CAS unit tests.
+       * CompilerErrorCollectionCas.cs: New. CAS unit tests.
+       * CompilerInfoCas.cs: New. CAS unit tests.
+       * CompilerParametersCas.cs: New. CAS unit tests.
+       * CompilerResultsCas.cs: New. CAS unit tests.
+       * GeneratedCodeAttributeCas.cs: New. CAS unit tests.
+       * GeneratedCodeAttributeTest.cs: New. Unit tests.
+       * IndentedTextWriterCas.cs: New. CAS unit tests.
+
 2005-10-15  Gert Driesen <drieseng@users.sourceforge.net>
 
        * CodeGeneratorTestBase.cs: No longer keep instance of StringWriter to
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorOptionsCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorOptionsCas.cs
new file mode 100644 (file)
index 0000000..1615180
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// CodeGeneratorOptionsCas.cs 
+//     - CAS unit tests for System.CodeDom.Compiler.CodeGeneratorOptions
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+using MonoTests.System.CodeDom.Compiler;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class CodeGeneratorOptionsCas {
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void ReuseUnitTests ()
+               {
+                       CodeGeneratorOptionsTest unit = new CodeGeneratorOptionsTest ();
+                       unit.Defaults ();
+                       unit.ReSetDefault ();
+                       unit.Nullify ();
+               }
+
+               [Test]
+               // no restriction
+               public void LinkDemand ()
+               {
+                       ConstructorInfo ci = typeof (CodeGeneratorOptions).GetConstructor (new Type[0]);
+                       Assert.IsNotNull (ci, "default .ctor()");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void LinkDemand_Deny_Anything ()
+               {
+                       // denying anything results in a non unrestricted permission set
+                       ConstructorInfo ci = typeof (CodeGeneratorOptions).GetConstructor (new Type[0]);
+                       Assert.IsNotNull (ci, "default .ctor()");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+       }
+}
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorOptionsTest.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CodeGeneratorOptionsTest.cs
new file mode 100644 (file)
index 0000000..61c51c1
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// CodeGeneratorOptionsTest.cs 
+//     - Unit tests for System.CodeDom.Compiler.CodeGeneratorOptions
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+
+namespace MonoTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       public class CodeGeneratorOptionsTest {
+
+               [Test]
+               public void Defaults ()
+               {
+                       CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
+                       Assert.IsTrue (cgo.BlankLinesBetweenMembers, "BlankLinesBetweenMembers");
+                       Assert.AreEqual ("Block", cgo.BracingStyle, "BracingStyle");
+                       Assert.IsFalse (cgo.ElseOnClosing, "ElseOnClosing");
+                       Assert.AreEqual ("    ", cgo.IndentString, "IndentString");
+#if NET_2_0
+                       Assert.IsFalse (cgo.VerbatimOrder, "VerbatimOrder");
+#endif
+                       Assert.IsNull (cgo["BlankLinesBetweenMembers"], "this[BlankLinesBetweenMembers]");
+                       Assert.IsNull (cgo["BracingStyle"], "this[BracingStyle]");
+                       Assert.IsNull (cgo["ElseOnClosing"], "this[ElseOnClosing]");
+                       Assert.IsNull (cgo["IndentString"], "this[IndentString]");
+#if NET_2_0
+                       Assert.IsNull (cgo["VerbatimOrder"], "this[VerbatimOrder]");
+#endif
+               }
+
+               [Test]
+               public void ReSetDefault ()
+               {
+                       CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
+
+                       cgo.BlankLinesBetweenMembers = cgo.BlankLinesBetweenMembers;
+                       Assert.IsNotNull (cgo["BlankLinesBetweenMembers"], "this[BlankLinesBetweenMembers]");
+                       cgo.BracingStyle = cgo.BracingStyle;
+                       Assert.IsNotNull (cgo["BracingStyle"], "this[BracingStyle]");
+                       cgo.ElseOnClosing = cgo.ElseOnClosing;
+                       Assert.IsNotNull (cgo["ElseOnClosing"], "this[ElseOnClosing]");
+                       cgo.IndentString = cgo.IndentString;
+                       Assert.IsNotNull (cgo["IndentString"], "this[IndentString]");
+#if NET_2_0
+                       cgo.VerbatimOrder = cgo.VerbatimOrder;
+                       Assert.IsNotNull (cgo["VerbatimOrder"], "this[VerbatimOrder]");
+#endif
+               }
+
+               [Test]
+               public void Nullify ()
+               {
+                       CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
+                       cgo.BlankLinesBetweenMembers = false;
+                       Assert.IsFalse (cgo.BlankLinesBetweenMembers, "BlankLinesBetweenMembers-1");
+                       cgo["BlankLinesBetweenMembers"] = null;
+                       Assert.IsTrue (cgo.BlankLinesBetweenMembers, "BlankLinesBetweenMembers-2");
+
+                       cgo.BracingStyle = "C";
+                       Assert.AreEqual ("C", cgo.BracingStyle, "BracingStyle-1");
+                       cgo["BracingStyle"] = null;
+                       Assert.AreEqual ("Block", cgo.BracingStyle, "BracingStyle-2");
+
+                       cgo.ElseOnClosing = true;
+                       Assert.IsTrue (cgo.ElseOnClosing, "ElseOnClosing-1");
+                       cgo["ElseOnClosing"] = null;
+                       Assert.IsFalse (cgo.ElseOnClosing, "ElseOnClosing-2");
+
+                       cgo.IndentString = "\t";
+                       Assert.AreEqual ("\t", cgo.IndentString, "IndentString-1");
+                       cgo["IndentString"] = null;
+                       Assert.AreEqual ("    ", cgo.IndentString, "IndentString-2");
+#if NET_2_0
+                       cgo.VerbatimOrder = true;
+                       Assert.IsTrue (cgo.VerbatimOrder, "VerbatimOrder-1");
+                       cgo["VerbatimOrder"] = null;
+                       Assert.IsFalse (cgo.VerbatimOrder, "VerbatimOrder-2");
+#endif
+               }
+       }
+}
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CodeParserCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CodeParserCas.cs
new file mode 100644 (file)
index 0000000..166bed5
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// CodeParserCas.cs 
+//     - CAS unit tests for System.CodeDom.Compiler.CodeParser
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+using MonoTests.System.CodeDom.Compiler;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       class CodeParserTest: CodeParser {
+
+               public override CodeCompileUnit Parse (TextReader codeStream)
+               {
+                       return new CodeCompileUnit ();
+               }
+       }
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class CodeParserCas {
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor ()
+               {
+                       CodeParserTest cp = new CodeParserTest ();
+                       Assert.IsNotNull (cp.Parse (null), "Parse");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       ConstructorInfo ci = typeof (CodeParserTest).GetConstructor (new Type[0]);
+                       Assert.IsNotNull (ci, "default .ctor");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+       }
+}
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CompilerErrorCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CompilerErrorCas.cs
new file mode 100644 (file)
index 0000000..6321e01
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// CompilerErrorCas.cs 
+//     - CAS unit tests for System.CodeDom.Compiler.CompilerError
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class CompilerErrorCas {
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+
+               private string fname;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       // at full trust
+                       fname = Path.GetTempFileName ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor0_Deny_Unrestricted ()
+               {
+                       CompilerError ce = new CompilerError ();
+                       Assert.AreEqual (0, ce.Column, "Column");
+                       ce.Column = 1;
+                       Assert.AreEqual (String.Empty, ce.ErrorNumber, "ErrorNumber");
+                       ce.ErrorNumber = "cs0000";
+                       Assert.AreEqual (String.Empty, ce.ErrorText, "ErrorText");
+                       ce.ErrorText = "error text";
+                       Assert.AreEqual (String.Empty, ce.FileName, "FileName");
+                       ce.FileName = fname;
+                       Assert.IsFalse (ce.IsWarning, "IsWarning");
+                       ce.IsWarning = true;
+                       Assert.AreEqual (0, ce.Line, "Line");
+                       ce.Line = 1;
+                       Assert.IsNotNull (ce.ToString (), "ToString");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor5_Deny_Unrestricted ()
+               {
+                       CompilerError ce = new CompilerError (fname, 1, 1, "cs0000", "error text");
+                       Assert.IsTrue ((ce.ToString ().IndexOf (fname) >= 0), "ToString");
+                       Assert.AreEqual (1, ce.Column, "Column");
+                       ce.Column = Int32.MinValue;
+                       Assert.AreEqual ("cs0000", ce.ErrorNumber, "ErrorNumber");
+                       ce.ErrorNumber = String.Empty;
+                       Assert.AreEqual ("error text", ce.ErrorText, "ErrorText");
+                       ce.ErrorText = String.Empty;
+                       Assert.AreEqual (fname, ce.FileName, "FileName");
+                       ce.FileName = String.Empty;
+                       Assert.IsFalse (ce.IsWarning, "IsWarning");
+                       ce.IsWarning = true;
+                       Assert.AreEqual (1, ce.Line, "Line");
+                       ce.Line = Int32.MinValue;
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       ConstructorInfo ci = typeof (CompilerError).GetConstructor (new Type [0]);
+                       Assert.IsNotNull (ci, "default .ctor()");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+       }
+}
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CompilerErrorCollectionCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CompilerErrorCollectionCas.cs
new file mode 100644 (file)
index 0000000..1e1a5e5
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// CompilerErrorCollectionCas.cs
+//     - CAS unit tests for System.CodeDom.Compiler.CompilerErrorCollection
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class CompilerErrorCollectionCas {
+
+               private CompilerError ce;
+               private CompilerError[] array;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       ce = new CompilerError ();
+                       array = new CompilerError[1] { ce };
+               }
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor0_Deny_Unrestricted ()
+               {
+                       CompilerErrorCollection coll = new CompilerErrorCollection ();
+                       Assert.AreEqual (0, coll.Add (ce), "Add");
+                       Assert.AreSame (ce, coll[0], "this[int]");
+                       coll[0] = ce;
+                       coll.CopyTo (array, 0);
+                       coll.AddRange (array);
+                       coll.AddRange (coll);
+                       Assert.IsTrue (coll.Contains (ce), "Contains");
+                       Assert.AreEqual (0, coll.IndexOf (ce), "IndexOf");
+                       coll.Insert (0, ce);
+                       coll.Remove (ce);
+                       ce.IsWarning = false;
+                       Assert.IsTrue (coll.HasErrors, "HasErrors");
+                       Assert.IsFalse (coll.HasWarnings, "HasWarnings");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor1_Deny_Unrestricted ()
+               {
+                       CompilerErrorCollection coll = new CompilerErrorCollection (array);
+                       coll.CopyTo (array, 0);
+                       Assert.AreEqual (1, coll.Add (ce), "Add");
+                       Assert.AreSame (ce, coll[0], "this[int]");
+                       coll[0] = ce;
+                       coll.AddRange (array);
+                       coll.AddRange (coll);
+                       Assert.IsTrue (coll.Contains (ce), "Contains");
+                       Assert.AreEqual (0, coll.IndexOf (ce), "IndexOf");
+                       coll.Insert (0, ce);
+                       coll.Remove (ce);
+                       ce.IsWarning = true;
+                       Assert.IsFalse (coll.HasErrors, "HasErrors");
+                       Assert.IsTrue (coll.HasWarnings, "HasWarnings");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor2_Deny_Unrestricted ()
+               {
+                       CompilerErrorCollection c = new CompilerErrorCollection ();
+                       CompilerErrorCollection coll = new CompilerErrorCollection (c);
+                       Assert.AreEqual (0, coll.Add (ce), "Add");
+                       Assert.AreSame (ce, coll[0], "this[int]");
+                       coll[0] = ce;
+                       coll.CopyTo (array, 0);
+                       coll.AddRange (array);
+                       coll.AddRange (coll);
+                       Assert.IsTrue (coll.Contains (ce), "Contains");
+                       Assert.AreEqual (0, coll.IndexOf (ce), "IndexOf");
+                       coll.Insert (0, ce);
+                       coll.Remove (ce);
+                       ce.IsWarning = false;
+                       Assert.IsTrue (coll.HasErrors, "HasErrors");
+                       Assert.IsFalse (coll.HasWarnings, "HasWarnings");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       ConstructorInfo ci = typeof (CompilerErrorCollection).GetConstructor (new Type[0]);
+                       Assert.IsNotNull (ci, "default .ctor");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+       }
+}
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CompilerInfoCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CompilerInfoCas.cs
new file mode 100644 (file)
index 0000000..4f7efcf
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// CompilerInfoCas.cs -
+//     CAS unit tests for System.CodeDom.Compiler.CompilerInfo
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+using MCSharp = Microsoft.CSharp;
+using MonoTests.System.CodeDom.Compiler;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       [Category ("NotWorking")] // FIXME: missing config stuff ???
+       public class CompilerInfoCas {
+
+               private CompilerInfo ci;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       ci = CodeDomProvider.GetCompilerInfo ("c#");
+               }
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+               
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Default ()
+               {
+                       Assert.AreEqual (typeof (MCSharp.CSharpCodeProvider), ci.CodeDomProviderType, "CodeDomProviderType");
+                       Assert.IsTrue (ci.IsCodeDomProviderTypeValid, "IsCodeDomProviderTypeValid");
+
+                       Assert.IsTrue (ci.Equals (ci), "Equals");
+                       Assert.IsTrue (ci.GetHashCode () != 0, "GetHashCode");
+                       Assert.AreEqual (2, ci.GetExtensions ().Length, "GetExtensions"); // .cs cs
+                       Assert.AreEqual (3, ci.GetLanguages ().Length, "GetLanguages"); // c# cs csharp
+
+                       try {
+                               Assert.IsNotNull (ci.CreateDefaultCompilerParameters (), "CreateDefaultCompilerParameters");
+                       }
+                       catch (NotImplementedException) {
+                               // mono
+                       }
+               }
+
+               [Test]
+               // no restriction
+               public void CreateProvider_No_Restriction ()
+               {
+                       Assert.IsNotNull (ci.CreateProvider (), "CreateProvider");
+               }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void CreateProvider_Deny_Anything ()
+               {
+                       ci.CreateProvider ();
+               }
+
+               [Test]
+               public void LinkDemand_No_Restriction ()
+               {
+                       MethodInfo mi = typeof (CompilerInfo).GetProperty ("IsCodeDomProviderTypeValid").GetGetMethod ();
+                       Assert.IsNotNull (mi, "IsCodeDomProviderTypeValid");
+                       Assert.IsTrue ((bool) mi.Invoke (ci, null), "invoke");
+               }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void LinkDemand_Deny_Anything ()
+               {
+                       // denying anything results in a non unrestricted permission set
+                       MethodInfo mi = typeof (CompilerInfo).GetProperty ("IsCodeDomProviderTypeValid").GetGetMethod ();
+                       Assert.IsNotNull (mi, "IsCodeDomProviderTypeValid");
+                       Assert.IsTrue ((bool) mi.Invoke (ci, null), "invoke");
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CompilerParametersCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CompilerParametersCas.cs
new file mode 100644 (file)
index 0000000..e65e937
--- /dev/null
@@ -0,0 +1,220 @@
+//
+// CompilerParametersCas.cs 
+//     - CAS unit tests for System.CodeDom.Compiler.CompilerParameters
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class CompilerParametersCas {
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor0_Deny_Unrestricted ()
+               {
+                       CompilerParameters cp = new CompilerParameters ();
+                       Assert.IsNull (cp.CompilerOptions, "CompilerOptions");
+                       cp.CompilerOptions = "-debug";
+                       Assert.IsNull (cp.Evidence, "Evidence");
+                       Assert.IsFalse (cp.GenerateExecutable, "GenerateExecutable");
+                       cp.GenerateExecutable = true;
+                       Assert.IsFalse (cp.GenerateInMemory, "GenerateInMemory");
+                       cp.GenerateInMemory = true;
+                       Assert.IsFalse (cp.IncludeDebugInformation, "IncludeDebugInformation");
+                       cp.IncludeDebugInformation = true;
+                       Assert.IsNull (cp.MainClass, "MainClass");
+                       cp.MainClass = "Program";
+                       Assert.IsNull (cp.OutputAssembly, "OutputAssembly");
+                       cp.OutputAssembly = "mono.dll";
+                       Assert.AreEqual (0, cp.ReferencedAssemblies.Count, "ReferencedAssemblies");
+                       Assert.AreEqual (0, cp.TempFiles.Count, "TempFiles");
+                       cp.TempFiles = new TempFileCollection ();
+                       Assert.AreEqual (IntPtr.Zero, cp.UserToken, "UserToken");
+                       cp.UserToken = (IntPtr) 1;
+                       Assert.AreEqual (-1, cp.WarningLevel, "WarningLevel");
+                       cp.WarningLevel = 0;
+                       Assert.IsNull (cp.Win32Resource, "Win32Resource");
+                       cp.Win32Resource = "*";
+#if NET_2_0
+                       Assert.AreEqual (0, cp.EmbeddedResources.Count, "EmbeddedResources");
+                       Assert.AreEqual (0, cp.LinkedResources.Count, "LinkedResources");
+#endif
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor1_Deny_Unrestricted ()
+               {
+                       CompilerParameters cp = new CompilerParameters (new string[1] { "mono.exe" });
+                       Assert.IsNull (cp.CompilerOptions, "CompilerOptions");
+                       cp.CompilerOptions = "-debug";
+                       Assert.IsNull (cp.Evidence, "Evidence");
+                       Assert.IsFalse (cp.GenerateExecutable, "GenerateExecutable");
+                       cp.GenerateExecutable = true;
+                       Assert.IsFalse (cp.GenerateInMemory, "GenerateInMemory");
+                       cp.GenerateInMemory = true;
+                       Assert.IsFalse (cp.IncludeDebugInformation, "IncludeDebugInformation");
+                       cp.IncludeDebugInformation = true;
+                       Assert.IsNull (cp.MainClass, "MainClass");
+                       cp.MainClass = "Program";
+                       Assert.IsNull (cp.OutputAssembly, "OutputAssembly");
+                       cp.OutputAssembly = "mono.dll";
+                       Assert.AreEqual (1, cp.ReferencedAssemblies.Count, "ReferencedAssemblies");
+                       Assert.AreEqual (0, cp.TempFiles.Count, "TempFiles");
+                       cp.TempFiles = new TempFileCollection ();
+                       Assert.AreEqual (IntPtr.Zero, cp.UserToken, "UserToken");
+                       cp.UserToken = (IntPtr) 1;
+                       Assert.AreEqual (-1, cp.WarningLevel, "WarningLevel");
+                       cp.WarningLevel = 0;
+                       Assert.IsNull (cp.Win32Resource, "Win32Resource");
+                       cp.Win32Resource = "*";
+#if NET_2_0
+                       Assert.AreEqual (0, cp.EmbeddedResources.Count, "EmbeddedResources");
+                       Assert.AreEqual (0, cp.LinkedResources.Count, "LinkedResources");
+#endif
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor2_Deny_Unrestricted ()
+               {
+                       CompilerParameters cp = new CompilerParameters (new string[1] { "mono.exe" }, "mono.dll");
+                       Assert.IsNull (cp.CompilerOptions, "CompilerOptions");
+                       cp.CompilerOptions = "-debug";
+                       Assert.IsNull (cp.Evidence, "Evidence");
+                       Assert.IsFalse (cp.GenerateExecutable, "GenerateExecutable");
+                       cp.GenerateExecutable = true;
+                       Assert.IsFalse (cp.GenerateInMemory, "GenerateInMemory");
+                       cp.GenerateInMemory = true;
+                       Assert.IsFalse (cp.IncludeDebugInformation, "IncludeDebugInformation");
+                       cp.IncludeDebugInformation = true;
+                       Assert.IsNull (cp.MainClass, "MainClass");
+                       cp.MainClass = "Program";
+                       Assert.AreEqual ("mono.dll", cp.OutputAssembly, "OutputAssembly");
+                       cp.OutputAssembly = null;
+                       Assert.AreEqual (1, cp.ReferencedAssemblies.Count, "ReferencedAssemblies");
+                       Assert.AreEqual (0, cp.TempFiles.Count, "TempFiles");
+                       cp.TempFiles = new TempFileCollection ();
+                       Assert.AreEqual (IntPtr.Zero, cp.UserToken, "UserToken");
+                       cp.UserToken = (IntPtr) 1;
+                       Assert.AreEqual (-1, cp.WarningLevel, "WarningLevel");
+                       cp.WarningLevel = 0;
+                       Assert.IsNull (cp.Win32Resource, "Win32Resource");
+                       cp.Win32Resource = "*";
+#if NET_2_0
+                       Assert.AreEqual (0, cp.EmbeddedResources.Count, "EmbeddedResources");
+                       Assert.AreEqual (0, cp.LinkedResources.Count, "LinkedResources");
+#endif
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor3_Deny_Unrestricted ()
+               {
+                       CompilerParameters cp = new CompilerParameters (new string[1] { "mono.exe" }, "mono.dll", true);
+                       Assert.IsNull (cp.CompilerOptions, "CompilerOptions");
+                       cp.CompilerOptions = "-debug";
+                       Assert.IsNull (cp.Evidence, "Evidence");
+                       Assert.IsFalse (cp.GenerateExecutable, "GenerateExecutable");
+                       cp.GenerateExecutable = true;
+                       Assert.IsFalse (cp.GenerateInMemory, "GenerateInMemory");
+                       cp.GenerateInMemory = true;
+                       Assert.IsTrue (cp.IncludeDebugInformation, "IncludeDebugInformation");
+                       cp.IncludeDebugInformation = false;
+                       Assert.IsNull (cp.MainClass, "MainClass");
+                       cp.MainClass = "Program";
+                       Assert.AreEqual ("mono.dll", cp.OutputAssembly, "OutputAssembly");
+                       cp.OutputAssembly = null;
+                       Assert.AreEqual (1, cp.ReferencedAssemblies.Count, "ReferencedAssemblies");
+                       Assert.AreEqual (0, cp.TempFiles.Count, "TempFiles");
+                       cp.TempFiles = new TempFileCollection ();
+                       Assert.AreEqual (IntPtr.Zero, cp.UserToken, "UserToken");
+                       cp.UserToken = (IntPtr) 1;
+                       Assert.AreEqual (-1, cp.WarningLevel, "WarningLevel");
+                       cp.WarningLevel = 0;
+                       Assert.IsNull (cp.Win32Resource, "Win32Resource");
+                       cp.Win32Resource = "*";
+#if NET_2_0
+                       Assert.AreEqual (0, cp.EmbeddedResources.Count, "EmbeddedResources");
+                       Assert.AreEqual (0, cp.LinkedResources.Count, "LinkedResources");
+#endif
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, ControlEvidence = true)]
+               public void Evidence_PermitOnly_Unrestricted ()
+               {
+                       CompilerParameters cp = new CompilerParameters ();
+                       cp.Evidence = new Evidence ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, ControlEvidence = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Evidence_Deny_Unrestricted ()
+               {
+                       CompilerParameters cp = new CompilerParameters ();
+                       cp.Evidence = new Evidence ();
+               }
+
+               [Test]
+               public void LinkDemand_No_Restriction ()
+               {
+                       ConstructorInfo ci = typeof (CompilerParameters).GetConstructor (new Type[0]);
+                       Assert.IsNotNull (ci, "default .ctor()");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void LinkDemand_Deny_Anything ()
+               {
+                       // denying anything results in a non unrestricted permission set
+                       ConstructorInfo ci = typeof (CompilerParameters).GetConstructor (new Type[0]);
+                       Assert.IsNotNull (ci, "default .ctor()");
+                       Assert.IsNotNull (ci.Invoke (null), "invoke");
+               }
+       }
+}
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/CompilerResultsCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/CompilerResultsCas.cs
new file mode 100644 (file)
index 0000000..5783e87
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// CompilerResultsCas.cs 
+//     - CAS unit tests for System.CodeDom.Compiler.CompilerResults
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Security.Policy;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class CompilerResultsCas {
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+
+               private TempFileCollection temps;
+               private Assembly assembly;
+               private string path;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       // at full trust
+                       temps = new TempFileCollection ();
+                       assembly = Assembly.GetExecutingAssembly ();
+                       path = assembly.Location;
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Deny_Unrestricted ()
+               {
+                       CompilerResults cr = new CompilerResults (temps);
+                       Assert.IsNull (cr.CompiledAssembly, "CompiledAssembly");
+                       cr.CompiledAssembly = assembly;
+                       Assert.AreEqual (0, cr.Errors.Count, "Errors");
+                       Assert.IsNull (cr.Evidence, "Evidence");
+                       Assert.AreEqual (0, cr.NativeCompilerReturnValue, "NativeCompilerReturnValue");
+                       cr.NativeCompilerReturnValue = 1;
+                       Assert.AreEqual (0, cr.Output.Count, "Output");
+                       Assert.IsNull (cr.PathToAssembly, "PathToAssembly");
+                       cr.PathToAssembly = path;
+                       Assert.AreEqual (0, cr.TempFiles.Count, "TempFiles");
+                       cr.TempFiles = new TempFileCollection ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, ControlEvidence = true)]
+               public void Evidence_PermitOnly_Unrestricted ()
+               {
+                       CompilerResults cr = new CompilerResults (temps);
+                       cr.Evidence = new Evidence ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, ControlEvidence = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Evidence_Deny_Unrestricted ()
+               {
+                       CompilerResults cr = new CompilerResults (temps);
+                       cr.Evidence = new Evidence ();
+               }
+
+               [Test]
+               public void LinkDemand_No_Restriction ()
+               {
+                       Type[] types = new Type[1] { typeof (TempFileCollection) };
+                       ConstructorInfo ci = typeof (CompilerResults).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(TempFileCollection)");
+                       Assert.IsNotNull (ci.Invoke (new object[1] { temps }), "invoke");
+               }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void LinkDemand_Deny_Anything ()
+               {
+                       // denying anything results in a non unrestricted permission set
+                       Type[] types = new Type[1] { typeof (TempFileCollection) };
+                       ConstructorInfo ci = typeof (CompilerResults).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(TempFileCollection)");
+                       Assert.IsNotNull (ci.Invoke (new object[1] { temps }), "invoke");
+               }
+       }
+}
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/GeneratedCodeAttributeCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/GeneratedCodeAttributeCas.cs
new file mode 100644 (file)
index 0000000..2593ce9
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// GeneratedCodeAttributeCas.cs 
+//     - CAS unit tests for System.CodeDom.Compiler.GeneratedCodeAttribute
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class GeneratedCodeAttributeCas {
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor_Deny_Unrestricted ()
+               {
+                       GeneratedCodeAttribute gca = new GeneratedCodeAttribute ("Mono", "1.2");
+                       Assert.AreEqual ("Mono", gca.Tool, "Tool");
+                       Assert.AreEqual ("1.2", gca.Version, "Version");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void LinkDemand_Deny_Unrestricted ()
+               {
+                       Type[] types = new Type[2] { typeof (string), typeof (string) };
+                       ConstructorInfo ci = typeof (GeneratedCodeAttribute).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(string,string)");
+                       Assert.IsNotNull (ci.Invoke (new object[2] { "Mono", "1.2" }), "invoke");
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/GeneratedCodeAttributeTest.cs b/mcs/class/System/Test/System.CodeDom.Compiler/GeneratedCodeAttributeTest.cs
new file mode 100644 (file)
index 0000000..16fb96c
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// GeneratedCodeAttributeTest.cs 
+//     - Unit tests for System.CodeDom.Compiler.GeneratedCodeAttribute
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+
+namespace MonoTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       public class GeneratedCodeAttributeTest {
+
+               [Test]
+               public void Constructor ()
+               {
+                       GeneratedCodeAttribute gca = new GeneratedCodeAttribute ("Mono", "1.2");
+                       Assert.AreEqual ("Mono", gca.Tool, "Tool");
+                       Assert.AreEqual ("1.2", gca.Version, "Version");
+               }
+
+               [Test]
+               public void Constructor_Null_Tool ()
+               {
+                       GeneratedCodeAttribute gca = new GeneratedCodeAttribute (null, "1.2");
+                       Assert.IsNull (gca.Tool, "Tool");
+                       Assert.AreEqual ("1.2", gca.Version, "Version");
+               }
+
+               [Test]
+               public void Constructor_Null_Version ()
+               {
+                       GeneratedCodeAttribute gca = new GeneratedCodeAttribute ("Mono", null);
+                       Assert.AreEqual ("Mono", gca.Tool, "Tool");
+                       Assert.IsNull (gca.Version, "Version");
+               }
+       }
+}
+
+#endif
diff --git a/mcs/class/System/Test/System.CodeDom.Compiler/IndentedTextWriterCas.cs b/mcs/class/System/Test/System.CodeDom.Compiler/IndentedTextWriterCas.cs
new file mode 100644 (file)
index 0000000..1789e2b
--- /dev/null
@@ -0,0 +1,141 @@
+//
+// IndentedTextWriterCas.cs 
+//     - CAS unit tests for System.CodeDom.Compiler.IndentedTextWriter
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.CodeDom.Compiler;
+using System.IO;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+
+namespace MonoCasTests.System.CodeDom.Compiler {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class IndentedTextWriterCas {
+
+               private TextWriter writer;
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       if (!SecurityManager.SecurityEnabled)
+                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+                       writer = new StringWriter ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Defaults_Deny_Unrestricted ()
+               {
+                       // note: CAS doesn't apply to fields
+                       Assert.AreEqual ("    ", IndentedTextWriter.DefaultTabString, "DefaultTabString");
+               }
+
+               private void TouchEverything (IndentedTextWriter itw)
+               {
+                       Assert.AreSame (writer.Encoding, itw.Encoding, "Encoding");
+                       Assert.AreEqual (0, itw.Indent, "Indent");
+                       itw.Indent = 1;
+                       Assert.AreSame (writer, itw.InnerWriter, "InnerWriter");
+                       Assert.AreEqual (writer.NewLine, itw.NewLine, "NewLine");
+
+                       itw.Write (true);
+                       itw.Write (Char.MinValue);
+                       itw.Write (Path.InvalidPathChars); // char[]
+                       itw.Write (Double.MinValue);
+                       itw.Write (Int32.MinValue);
+                       itw.Write (Int64.MaxValue);
+                       itw.Write (new object ());
+                       itw.Write (Single.MinValue);
+                       itw.Write (String.Empty);
+                       itw.Write ("{0}", String.Empty);
+                       itw.Write ("{0}{1}", Int32.MinValue, Int32.MaxValue);
+                       itw.Write ("{0}{1}{2}", Int32.MinValue, 0, Int32.MaxValue);
+                       itw.Write (Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
+                       itw.WriteLine ();
+                       itw.WriteLine (true);
+                       itw.WriteLine (Char.MinValue);
+                       itw.WriteLine (Path.InvalidPathChars); // char[]
+                       itw.WriteLine (Double.MinValue);
+                       itw.WriteLine (Int32.MinValue);
+                       itw.WriteLine (Int64.MaxValue);
+                       itw.WriteLine (new object ());
+                       itw.WriteLine (Single.MinValue);
+                       itw.WriteLine (String.Empty);
+                       itw.WriteLine (UInt32.MaxValue);
+                       itw.WriteLine ("{0}", String.Empty);
+                       itw.WriteLine ("{0}{1}", Int32.MinValue, Int32.MaxValue);
+                       itw.WriteLine ("{0}{1}{2}", Int32.MinValue, 0, Int32.MaxValue);
+                       itw.WriteLine (Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
+                       itw.WriteLineNoTabs (String.Empty);
+                       itw.Flush ();
+                       itw.Close ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor1_Deny_Unrestricted ()
+               {
+                       IndentedTextWriter itw = new IndentedTextWriter (writer);
+                       TouchEverything (itw);
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor2_Deny_Unrestricted ()
+               {
+                       IndentedTextWriter itw = new IndentedTextWriter (writer, "\t");
+                       TouchEverything (itw);
+               }
+
+               [Test]
+               public void LinkDemand_No_Restriction ()
+               {
+                       Type[] types = new Type[1] { typeof (TextWriter) };
+                       ConstructorInfo ci = typeof (IndentedTextWriter).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(TextWriter)");
+                       Assert.IsNotNull (ci.Invoke (new object[1] { writer }), "invoke");
+               }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void LinkDemand_Deny_Anything ()
+               {
+                       // denying anything results in a non unrestricted permission set
+                       Type[] types = new Type[1] { typeof (TextWriter) };
+                       ConstructorInfo ci = typeof (IndentedTextWriter).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(TextWriter)");
+                       Assert.IsNotNull (ci.Invoke (new object[1] { writer }), "invoke");
+               }
+       }
+}