Author: spouliot
Date: 2008-02-15 15:00:48 -0500 (Fri, 15 Feb 2008)
New Revision: 95815

Modified:
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ArrayFieldsShouldNotBeReadOnlyTest.cs
   trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ChangeLog
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/MethodCallWithSubsetLinkDemandTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NativeFieldsShouldNotBeVisibleTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NonVirtualMethodWithInheritanceDemandTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SealedTypeWithInheritanceDemandTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SecureGetObjectDataOverridesTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/StaticConstructorsShouldBePrivateTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeExposeFieldsTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeIsNotSubsetOfMethodSecurityTest.cs
   
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeLinkDemandTest.cs
Log:
2008-02-15  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * ArrayFieldsShouldNotBeReadOnlyTest.cs
        * MethodCallWithSubsetLinkDemandTest.cs
        * NativeFieldsShouldNotBeVisibleTest.cs
        * NonVirtualMethodWithInheritanceDemandTest.cs
        * SealedTypeWithInheritanceDemandTest.cs
        * SecureGetObjectDataOverridesTest.cs
        * StaticConstructorsShouldBePrivateTest.cs
        * TypeExposeFieldsTest.cs
        * TypeIsNotSubsetOfMethodSecurityTest.cs
        * TypeLinkDemandTest.cs:
                Updated unit tests wrt framework changes.



Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ArrayFieldsShouldNotBeReadOnlyTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ArrayFieldsShouldNotBeReadOnlyTest.cs
  2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ArrayFieldsShouldNotBeReadOnlyTest.cs
  2008-02-15 20:00:48 UTC (rev 95815)
@@ -68,6 +68,7 @@
        public class ArrayFieldsShouldNotBeReadOnlyTest {
 
                private ArrayFieldsShouldNotBeReadOnlyRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
 
 
@@ -77,6 +78,7 @@
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
                        rule = new ArrayFieldsShouldNotBeReadOnlyRule ();
+                       runner = new TestRunner (rule);
                }
 
                public TypeDefinition GetTest (string name)
@@ -88,49 +90,49 @@
                public void TestHasStaticPublicReadonlyArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasStaticPublicReadonlyArray");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPublicReadonlyArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicReadonlyArray");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasProtectedReadonlyArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasProtectedReadonlyArray");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasInternalReadonlyArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasInternalReadonlyArray");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPrivateReadonlyArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPrivateReadonlyArray");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasNoReadonlyArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasNoReadonlyArray");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPublicArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicArray");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
        }
 }

Modified: trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ChangeLog
===================================================================
--- trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ChangeLog      
2008-02-15 19:58:07 UTC (rev 95814)
+++ trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/ChangeLog      
2008-02-15 20:00:48 UTC (rev 95815)
@@ -1,3 +1,17 @@
+2008-02-15  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * ArrayFieldsShouldNotBeReadOnlyTest.cs
+       * MethodCallWithSubsetLinkDemandTest.cs
+       * NativeFieldsShouldNotBeVisibleTest.cs
+       * NonVirtualMethodWithInheritanceDemandTest.cs
+       * SealedTypeWithInheritanceDemandTest.cs
+       * SecureGetObjectDataOverridesTest.cs
+       * StaticConstructorsShouldBePrivateTest.cs
+       * TypeExposeFieldsTest.cs
+       * TypeIsNotSubsetOfMethodSecurityTest.cs
+       * TypeLinkDemandTest.cs:
+               Updated unit tests wrt framework changes.
+
 2008-01-21  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * NativeFieldsShouldNotBeVisibleTest.cs: New. Unit tests by 

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/MethodCallWithSubsetLinkDemandTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/MethodCallWithSubsetLinkDemandTest.cs
  2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/MethodCallWithSubsetLinkDemandTest.cs
  2008-02-15 20:00:48 UTC (rev 95815)
@@ -105,16 +105,16 @@
                }
 
                private IMethodRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private ModuleDefinition module;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
-                       module = assembly.MainModule;
                        rule = new MethodCallWithSubsetLinkDemandRule ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest (string name)
@@ -128,7 +128,7 @@
                {
                        TypeDefinition type = GetTest ("SubsetInheritClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()), method.ToString ());
+                               Assert.AreEqual (RuleResult.Success, 
runner.CheckMethod (method), method.ToString ());
                        }
                }
 
@@ -137,8 +137,7 @@
                {
                        TypeDefinition type = GetTest 
("NotASubsetInheritClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               int n = rule.CheckMethod (method, new 
MinimalRunner ()).Count;
-                               Assert.AreEqual (0, n, method.ToString ());
+                               Assert.AreEqual (RuleResult.Failure, 
runner.CheckMethod (method), method.ToString ());
                        }
                }
 
@@ -147,7 +146,7 @@
                {
                        TypeDefinition type = GetTest ("SubsetCallClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()), method.ToString ());
+                               Assert.AreEqual (RuleResult.Success, 
runner.CheckMethod (method), method.ToString ());
                        }
                }
 
@@ -156,8 +155,7 @@
                {
                        TypeDefinition type = GetTest ("NotASubsetCallClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               int n = rule.CheckMethod (method, new 
MinimalRunner ()).Count;
-                               Assert.AreEqual (0, n, method.ToString ());
+                               Assert.AreEqual (RuleResult.Failure, 
runner.CheckMethod (method), method.ToString ());
                        }
                }
        }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NativeFieldsShouldNotBeVisibleTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NativeFieldsShouldNotBeVisibleTest.cs
  2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NativeFieldsShouldNotBeVisibleTest.cs
  2008-02-15 20:00:48 UTC (rev 95815)
@@ -76,6 +76,7 @@
        public class NativeFieldsShouldNotBeVisibleTest {
 
                private NativeFieldsShouldNotBeVisibleRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
 
 
@@ -85,6 +86,7 @@
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
                        rule = new NativeFieldsShouldNotBeVisibleRule ();
+                       runner = new TestRunner (rule);
                }
 
                public TypeDefinition GetTest (string name)
@@ -96,64 +98,63 @@
                public void TestHasPublicNativeField ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicNativeField");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasProtectedNativeField ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasProtectedNativeField");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasInternalNativeField ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasInternalNativeField");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPublicReadonlyNativeField ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicReadonlyNativeField");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPublicNativeFieldArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicNativeFieldArray");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPublicReadonlyNativeFieldArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicReadonlyNativeFieldArray");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPublicNativeFieldArrayArray ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicNativeFieldArrayArray");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
-
                [Test]
                public void TestHasPublicNonNativeField ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPublicNonNativeField");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void TestHasPrivateNativeField ()
                {
                        TypeDefinition type = GetTest 
("Test.Rules.Security.HasPrivateNativeField");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
        }
 }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NonVirtualMethodWithInheritanceDemandTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NonVirtualMethodWithInheritanceDemandTest.cs
   2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/NonVirtualMethodWithInheritanceDemandTest.cs
   2008-02-15 20:00:48 UTC (rev 95815)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2005-2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2006,2008 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
@@ -46,12 +46,12 @@
                public abstract class AbstractMethodsClass {
 
                        [SecurityPermission 
(SSP.SecurityAction.InheritanceDemand, ControlAppDomain = true)]
-                       public abstract void Asbtract ();
+                       public abstract void Abstract ();
                }
 
                public class VirtualMethodsClass: AbstractMethodsClass  {
 
-                       public override void Asbtract ()
+                       public override void Abstract ()
                        {
                        }
 
@@ -96,16 +96,16 @@
                }
 
                private IMethodRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private ModuleDefinition module;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
-                       module = assembly.MainModule;
                        rule = new NonVirtualMethodWithInheritanceDemandRule ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest (string name)
@@ -119,7 +119,7 @@
                {
                        TypeDefinition type = GetTest ("AbstractMethodsClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                               Assert.AreEqual (RuleResult.Success, 
runner.CheckMethod (method), method.ToString ());
                        }
                }
 
@@ -128,7 +128,14 @@
                {
                        TypeDefinition type = GetTest ("VirtualMethodsClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                               switch (method.Name) {
+                               case "Abstract":
+                                       Assert.AreEqual 
(RuleResult.DoesNotApply, runner.CheckMethod (method), method.Name);
+                                       break;
+                               case "Virtual":
+                                       Assert.AreEqual (RuleResult.Success, 
runner.CheckMethod (method), method.Name);
+                                       break;
+                               }
                        }
                }
 
@@ -137,8 +144,7 @@
                {
                        TypeDefinition type = GetTest ("NoVirtualMethodsClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               int n = rule.CheckMethod (method, new 
MinimalRunner ()).Count;
-                               Assert.AreEqual (0, n, method.ToString ());
+                               Assert.AreEqual (RuleResult.Failure, 
runner.CheckMethod (method), method.ToString ());
                        }
                }
 
@@ -147,7 +153,7 @@
                {
                        TypeDefinition type = GetTest 
("NotInheritanceDemandClass");
                        foreach (MethodDefinition method in type.Methods) {
-                               Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                               Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckMethod (method), method.ToString ());
                        }
                }
        }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SealedTypeWithInheritanceDemandTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SealedTypeWithInheritanceDemandTest.cs
 2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SealedTypeWithInheritanceDemandTest.cs
 2008-02-15 20:00:48 UTC (rev 95815)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2005-2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2006,2008 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
@@ -72,16 +72,16 @@
                }
 
                private ITypeRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private ModuleDefinition module;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
-                       module = assembly.MainModule;
                        rule = new SealedTypeWithInheritanceDemandRule ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest (string name)
@@ -94,29 +94,28 @@
                public void NonSealed ()
                {
                        TypeDefinition type = GetTest ("NonSealedClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void SealedWithoutSecurity ()
                {
                        TypeDefinition type = GetTest 
("SealedClassWithoutSecurity");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void SealedWithoutInheritanceDemand ()
                {
                        TypeDefinition type = GetTest 
("SealedClassWithoutInheritanceDemand");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void SealedWithInheritanceDemand ()
                {
                        TypeDefinition type = GetTest 
("SealedClassWithInheritanceDemand");
-                       int n = rule.CheckType (type, new MinimalRunner 
()).Count;
-                       Assert.AreEqual (0, n, type.ToString ());
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
        }
 }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SecureGetObjectDataOverridesTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SecureGetObjectDataOverridesTest.cs
    2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/SecureGetObjectDataOverridesTest.cs
    2008-02-15 20:00:48 UTC (rev 95815)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005,2008 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
@@ -57,12 +57,12 @@
                        {
                        }
 
-                       public void GetObjectData(SerializationInfo info, 
StreamingContext context)
+                       public virtual void GetObjectData(SerializationInfo 
info, StreamingContext context)
                        {
                        }
                }
 
-               public class InheritISerializableClass : NameValueCollection {
+               public class InheritISerializableClass : ISerializableClass {
 
                        public InheritISerializableClass ()
                        {
@@ -121,17 +121,17 @@
                        }
                }
 
-               private IMethodRule rule;
+               private ITypeRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private ModuleDefinition module;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
-                       module = assembly.MainModule;
                        rule = new SecureGetObjectDataOverridesRule ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest (string name)
@@ -140,71 +140,54 @@
                        return assembly.MainModule.Types[fullname];
                }
 
-               private MethodDefinition GetObjectData (TypeDefinition type)
-               {
-                       foreach (MethodDefinition method in type.Methods) {
-                               if (method.Name == "GetObjectData")
-                                       return method;
-                       }
-                       return null;
-               }
-
                [Test]
                public void Serializable ()
                {
                        TypeDefinition type = GetTest ("SerializableClass");
                        // there's no GetObjectData method here so the test 
should never fail
-                       foreach (MethodDefinition method in type.Methods) {
-                               Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()));
-                       }
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
rule.CheckType (type));
                }
 
                [Test]
                public void ISerializable ()
                {
                        TypeDefinition type = GetTest ("ISerializableClass");
-                       MethodDefinition method = GetObjectData (type);
-                       Assert.IsNotNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void InheritISerializable ()
                {
                        TypeDefinition type = GetTest 
("InheritISerializableClass");
-                       MethodDefinition method = GetObjectData (type);
-                       Assert.IsNotNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void LinkDemand ()
                {
                        TypeDefinition type = GetTest ("LinkDemandClass");
-                       MethodDefinition method = GetObjectData (type);
-                       Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void InheritanceDemand ()
                {
                        TypeDefinition type = GetTest 
("InheritanceDemandClass");
-                       MethodDefinition method = GetObjectData (type);
-                       Assert.IsNotNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void Demand ()
                {
                        TypeDefinition type = GetTest ("DemandClass");
-                       MethodDefinition method = GetObjectData (type);
-                       Assert.IsNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void DemandWrongPermission ()
                {
                        TypeDefinition type = GetTest 
("DemandWrongPermissionClass");
-                       MethodDefinition method = GetObjectData (type);
-                       Assert.IsNotNull (rule.CheckMethod (method, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
        }
 }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/StaticConstructorsShouldBePrivateTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/StaticConstructorsShouldBePrivateTest.cs
       2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/StaticConstructorsShouldBePrivateTest.cs
       2008-02-15 20:00:48 UTC (rev 95815)
@@ -48,8 +48,8 @@
        public class StaticConstructorsShouldBePrivateTest {
 
                private ITypeRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private Runner runner;
 
 
                [TestFixtureSetUp]
@@ -58,7 +58,7 @@
                        string unit = 
System.Reflection.Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
                        rule = new StaticConstructorsShouldBePrivateRule ();
-                       runner = new MinimalRunner ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest<T> ()
@@ -69,15 +69,13 @@
                [Test]
                public void TestNoStaticCtorDefinedClass ()
                {
-                       MessageCollection messages = rule.CheckType 
(GetTest<NoStaticCtorDefinedClass> (), runner);
-                       Assert.IsNull (messages);
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(GetTest<NoStaticCtorDefinedClass> ()));
                }
 
                [Test]
                public void TestPrivateStaticCtorDefinedClass ()
                {
-                       MessageCollection messages = rule.CheckType 
(GetTest<PrivateStaticCtorDefinedClass> (), runner);
-                       Assert.IsNull (messages);
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(GetTest<PrivateStaticCtorDefinedClass> ()));
                }
 
                [Test]
@@ -88,9 +86,8 @@
                                if (ctor.IsStatic)
                                        ctor.IsPublic = true; // change it from 
private to public
 
-                       MessageCollection messages = rule.CheckType 
(inspectedType, runner);
-                       Assert.IsNotNull (messages);
-                       Assert.AreEqual (1, messages.Count);
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(inspectedType), inspectedType.FullName);
+                       Assert.AreEqual (1, runner.Defects.Count, "Count");
                }
        }
 }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeExposeFieldsTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeExposeFieldsTest.cs
        2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeExposeFieldsTest.cs
        2008-02-15 20:00:48 UTC (rev 95815)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005,2008 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
@@ -101,16 +101,16 @@
                }
 
                private ITypeRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private ModuleDefinition module;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
-                       module = assembly.MainModule;
                        rule = new TypeExposeFieldsRule ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest (string name)
@@ -123,42 +123,42 @@
                public void NonPublic ()
                {
                        TypeDefinition type = GetTest ("NonPublicClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void NoSecurity ()
                {
                        TypeDefinition type = GetTest ("NoSecurityClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void NoDemand ()
                {
                        TypeDefinition type = GetTest ("NoDemandClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void NoPublicField ()
                {
                        TypeDefinition type = GetTest ("NoPublicFieldClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void LinkDemandWithField ()
                {
                        TypeDefinition type = GetTest 
("LinkDemandWithFieldClass");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void DemandWithField ()
                {
                        TypeDefinition type = GetTest ("DemandWithFieldClass");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
        }
 }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeIsNotSubsetOfMethodSecurityTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeIsNotSubsetOfMethodSecurityTest.cs
 2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeIsNotSubsetOfMethodSecurityTest.cs
 2008-02-15 20:00:48 UTC (rev 95815)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005,2008 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
@@ -127,16 +127,16 @@
                }
 
                private ITypeRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private ModuleDefinition module;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
-                       module = assembly.MainModule;
                        rule = new TypeIsNotSubsetOfMethodSecurityRule ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest (string name)
@@ -149,49 +149,49 @@
                public void NoSecurity ()
                {
                        TypeDefinition type = GetTest ("NoSecurityClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void LinkDemand ()
                {
                        TypeDefinition type = GetTest ("LinkDemandClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void InheritanceDemand ()
                {
                        TypeDefinition type = GetTest 
("InheritanceDemandClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void AssertNotSubset ()
                {
                        TypeDefinition type = GetTest ("AssertNotSubsetClass");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void DemandSubset ()
                {
                        TypeDefinition type = GetTest ("DemandSubsetClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
 
                [Test]
                public void DenyNotSubset ()
                {
                        TypeDefinition type = GetTest ("DenyNotSubsetClass");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void PermitOnlySubset ()
                {
                        TypeDefinition type = GetTest ("PermitOnlySubsetClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
        }
 }

Modified: 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeLinkDemandTest.cs
===================================================================
--- 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeLinkDemandTest.cs
  2008-02-15 19:58:07 UTC (rev 95814)
+++ 
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Security/Test/TypeLinkDemandTest.cs
  2008-02-15 20:00:48 UTC (rev 95815)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005,2008 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
@@ -125,16 +125,16 @@
                }
 
                private ITypeRule rule;
+               private TestRunner runner;
                private AssemblyDefinition assembly;
-               private ModuleDefinition module;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
                        string unit = Assembly.GetExecutingAssembly ().Location;
                        assembly = AssemblyFactory.GetAssembly (unit);
-                       module = assembly.MainModule;
                        rule = new TypeLinkDemandRule ();
+                       runner = new TestRunner (rule);
                }
 
                private TypeDefinition GetTest (string name)
@@ -147,56 +147,56 @@
                public void NonPublic ()
                {
                        TypeDefinition type = GetTest ("NonPublicClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void Sealed ()
                {
                        TypeDefinition type = GetTest ("SealedClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void LinkDemand ()
                {
                        TypeDefinition type = GetTest ("LinkDemandClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void LinkDemandVirtualMethod ()
                {
                        TypeDefinition type = GetTest 
("LinkDemandVirtualMethodClass");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void InheritanceDemand ()
                {
                        TypeDefinition type = GetTest 
("InheritanceDemandClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void NoIntersection ()
                {
                        TypeDefinition type = GetTest ("NoIntersectionClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.DoesNotApply, 
runner.CheckType (type));
                }
 
                [Test]
                public void NoIntersectionVirtualMethod ()
                {
                        TypeDefinition type = GetTest 
("NoIntersectionVirtualMethodClass");
-                       Assert.IsNotNull (rule.CheckType (type, new 
MinimalRunner ()));
+                       Assert.AreEqual (RuleResult.Failure, runner.CheckType 
(type));
                }
 
                [Test]
                public void Intersection ()
                {
                        TypeDefinition type = GetTest ("IntersectionClass");
-                       Assert.IsNull (rule.CheckType (type, new MinimalRunner 
()));
+                       Assert.AreEqual (RuleResult.Success, runner.CheckType 
(type));
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to