Author: spouliot
Date: 2008-01-02 11:23:27 -0500 (Wed, 02 Jan 2008)
New Revision: 92112

Modified:
   trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/ChangeLog
   
trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/MethodRocksTest.cs
   trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/TypeRocksTest.cs
Log:
2008-01-02  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * MethodRocksTest.cs: Added test cases for IsProperty
        * TypeRocksTest.cs: Added test cases for IsAttribute, IsArray and 
        Inherits



Modified: trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/ChangeLog
===================================================================
--- trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/ChangeLog      
2008-01-02 16:20:01 UTC (rev 92111)
+++ trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/ChangeLog      
2008-01-02 16:23:27 UTC (rev 92112)
@@ -1,3 +1,9 @@
+2008-01-02  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * MethodRocksTest.cs: Added test cases for IsProperty
+       * TypeRocksTest.cs: Added test cases for IsAttribute, IsArray and 
+       Inherits
+
 2007-12-26  Sebastien Pouliot  <[EMAIL PROTECTED]> 
 
        * CustomAttributeRocksTest.cs: New. Unit tests for CustomAttributeRocks

Modified: 
trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/MethodRocksTest.cs
===================================================================
--- 
trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/MethodRocksTest.cs 
    2008-01-02 16:20:01 UTC (rev 92111)
+++ 
trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/MethodRocksTest.cs 
    2008-01-02 16:23:27 UTC (rev 92112)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot  <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2007-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 "Software"), to 
deal
@@ -144,6 +144,14 @@
                }
 
                [Test]
+               public void IsProperty ()
+               {
+                       Assert.IsTrue (GetMethod ("get_Value").IsProperty (), 
"get_Value");
+                       Assert.IsTrue (GetMethod ("set_Value").IsProperty (), 
"set_Value");
+                       Assert.IsFalse (GetMethod ("FixtureSetUp").IsProperty 
(), "FixtureSetUp");
+               }
+
+               [Test]
                public void IsSetter ()
                {
                        Assert.IsFalse (GetMethod ("get_Value").IsSetter (), 
"get_Value");

Modified: 
trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/TypeRocksTest.cs
===================================================================
--- 
trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/TypeRocksTest.cs   
    2008-01-02 16:20:01 UTC (rev 92111)
+++ 
trunk/cecil/gendarme/framework/Test/Gendarme.Framework.Rocks/TypeRocksTest.cs   
    2008-01-02 16:23:27 UTC (rev 92112)
@@ -3,8 +3,10 @@
 //
 // Authors:
 //     Sebastien Pouliot  <[EMAIL PROTECTED]>
+//      Daniel Abramov <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2007-2008 Novell, Inc (http://www.novell.com)
+// (C) 2007 Daniel Abramov
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to 
deal
@@ -57,6 +59,32 @@
                        }
                }
 
+               class NotAttribute {
+               }
+
+               class AnAttribute : Attribute {
+               }
+
+               class ClassInheritsNotAttribute : NotAttribute {
+               }
+
+               class AttributeInheritsAnAttribute : AnAttribute {
+               }
+
+               class AttributeInheritsOuterAttribute : ContextStaticAttribute {
+               }
+
+               class AttributeInheritsOuterAttributeDerivingAttribute : 
AttributeInheritsOuterAttribute {
+               }
+
+               private byte [] array_of_bytes;
+               private Enum [] array_of_enum;
+               private Flags [] array_of_flags;
+               private string [] array_of_strings;
+               private Deep [] array_of_classes;
+               private ICloneable [] array_of_interfaces;
+
+
                private AssemblyDefinition assembly;
 
                [TestFixtureSetUp]
@@ -71,6 +99,17 @@
                        return assembly.MainModule.Types 
["Test.Framework.Rocks.TypeRocksTest" + name];
                }
 
+               private TypeReference GetFieldType (string name)
+               {
+                       TypeDefinition type = assembly.MainModule.Types 
["Test.Framework.Rocks.TypeRocksTest"];
+                       foreach (FieldDefinition field in type.Fields) {
+                               if (name == field.Name)
+                                       return field.FieldType;
+                       }
+                       Assert.Fail (name);
+                       return null;
+               }
+
                [Test]
                [ExpectedException (typeof (ArgumentNullException))]
                public void HasAttribute_Null ()
@@ -107,6 +146,73 @@
                }
 
                [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void Inherits_Null ()
+               {
+                       GetType (String.Empty).Inherits (null);
+               }
+
+               [Test]
+               public void Inherits ()
+               {
+                       Assert.IsFalse (GetType ("/NotAttribute").Inherits 
("System.Attribute"), "NotAttribute");
+                       Assert.IsTrue (GetType ("/AnAttribute").Inherits 
("System.Attribute"), "AnAttribute");
+                       Assert.IsFalse (GetType 
("/ClassInheritsNotAttribute").Inherits ("System.Attribute"), 
"ClassInheritsNotAttribute");
+                       Assert.IsTrue (GetType 
("/AttributeInheritsAnAttribute").Inherits ("System.Attribute"), 
"AttributeInheritsAnAttribute");
+               }
+
+               [Test]
+               [Ignore ("cannot be sure without the AssemblyResolver")]
+               public void Inherits_FromAnotherAssembly ()
+               {
+                       // we can't be sure here so to avoid false positives 
return false
+                       Assert.IsTrue (GetType 
("/AttributeInheritsOuterAttribute").Inherits ("System.Attribute"), 
"AttributeInheritsOuterAttribute");
+                       Assert.IsTrue (GetType 
("/AttributeInheritsOuterAttributeDerivingAttribute").Inherits 
("System.Attribute"), "AttributeInheritsOuterAttributeDerivingAttribute");
+               }
+
+               [Test]
+               public void Inherits_Itself ()
+               {
+                       TypeDefinition type = GetType (String.Empty);
+                       Assert.IsTrue (type.Inherits (type.FullName), "itself");
+               }
+
+               [Test]
+               public void IsArray ()
+               {
+                       Assert.IsTrue (GetFieldType ("array_of_bytes").IsArray 
(), "array_of_bytes");
+                       Assert.IsTrue (GetFieldType 
("array_of_strings").IsArray (), "array_of_strings");
+                       Assert.IsTrue (GetFieldType 
("array_of_interfaces").IsArray (), "array_of_interfaces");
+
+                       Assert.IsFalse (GetType ("/AnAttribute").IsArray (), 
"AnAttribute");
+                       Assert.IsTrue (GetFieldType 
("array_of_classes").IsArray (), "array_of_classes");
+
+                       Assert.IsFalse (GetType ("/Enum").IsArray (), "Enum");
+                       Assert.IsTrue (GetFieldType ("array_of_enum").IsArray 
(), "array_of_enum");
+
+                       Assert.IsFalse (GetType ("/Flags").IsArray (), "Flags");
+                       Assert.IsTrue (GetFieldType ("array_of_flags").IsArray 
(), "array_of_flags");
+               }
+
+               [Test]
+               public void IsAttribute ()
+               {
+                       Assert.IsFalse (GetType ("/NotAttribute").IsAttribute 
(), "NotAttribute");
+                       Assert.IsTrue (GetType ("/AnAttribute").IsAttribute (), 
"AnAttribute");
+                       Assert.IsFalse (GetType 
("/ClassInheritsNotAttribute").IsAttribute (), "ClassInheritsNotAttribute");
+                       Assert.IsTrue (GetType 
("/AttributeInheritsAnAttribute").IsAttribute (), 
"AttributeInheritsAnAttribute");
+               }
+
+               [Test]
+               [Ignore ("cannot be sure without the AssemblyResolver")]
+               public void IsAttribute_InheritsFromAnotherAssembly ()
+               {
+                       // we can't be sure here so to avoid false positives 
return false
+                       Assert.IsTrue (GetType 
("/AttributeInheritsOuterAttribute").IsAttribute (), 
"AttributeInheritsOuterAttribute");
+                       Assert.IsTrue (GetType 
("/AttributeInheritsOuterAttributeDerivingAttribute").IsAttribute (), 
"AttributeInheritsOuterAttributeDerivingAttribute");
+               }
+
+               [Test]
                public void IsFlags ()
                {
                        Assert.IsFalse (GetType (String.Empty).IsFlags (), 
"Type.IsFlags");

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

Reply via email to