context: // 
  // Unit tests for TypeRocks
  //
  // Authors:
  //	Sebastien Pouliot  <sebastien@ximian.com>
  //      Daniel Abramov <ex@vingrad.ru>
  //	Andreas Noever <andreas.noever@gmail.com>
  //
  // Copyright (C) 2007-2008 Novell, Inc (http://www.novell.com)
  // (C) 2007 Daniel Abramov
  // (C) 2008 Andreas Noever
  //
  // 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 System;
  using System.Runtime.InteropServices;
  
  using Gendarme.Framework;
  using Gendarme.Framework.Helpers;
  using Gendarme.Framework.Rocks;
  
  using Mono.Cecil;
  using NUnit.Framework;
  
  namespace Test.Framework.Rocks {
  
  	[TestFixture]
  	public class TypeRocksTest {
  
  		[System.Runtime.CompilerServices.CompilerGeneratedAttribute]
  		public class TypeCompilerGenerated {
  		}
  
  		[System.CodeDom.Compiler.GeneratedCodeAttribute ("unit test", "1.0")]
  		public class TypeGeneratedCode {
  		}
  
  		public enum Enum {
  			Value
  		}
  
  		[Flags]
  		public enum Flags {
  			Mask
  		}
  
  		interface IDeepCloneable : ICloneable {
  		}
  
  		class Deep : IDeepCloneable {
  			public object Clone ()
  			{
  				throw new NotImplementedException ();
  			}
  		}
  
  		interface  IInterface1 {
  		}
  
  		interface IInterface2 : IDeepCloneable {
  		}
  
  		interface IMixinInterface : IInterface1, IInterface2 {
  		}
  
  		class Mixin : IMixinInterface {
  			public object Clone ()
  			{
  				throw new NotImplementedException ();
  			}
  		}
  
  		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 float SingleValue;
  		private double DoubleValue;
  
  		private IntPtr IntPtrValue;
  		private UIntPtr UIntPtrValue;
  		private HandleRef HandleRefValue;
  
  		public void MethodA (bool parameter) { }
  
  
  		private AssemblyDefinition assembly;
  		private TypeDefinition type;
  
  		[TestFixtureSetUp]
  		public void FixtureSetUp ()
  		{
  			string unit = System.Reflection.Assembly.GetExecutingAssembly ().Location;
  			assembly = AssemblyDefinition.ReadAssembly (unit);
  			type = assembly.MainModule.GetType ("Test.Framework.Rocks.TypeRocksTest");
  		}
  
  		private TypeDefinition GetType (string name)
  		{
  			return assembly.MainModule.GetType ("Test.Framework.Rocks.TypeRocksTest" + name);
  		}
  
  		private TypeReference GetFieldType (string name)
  		{
  			TypeDefinition type = assembly.MainModule.GetType ("Test.Framework.Rocks.TypeRocksTest");
  			foreach (FieldDefinition field in type.Fields) {
  				if (name == field.Name)
  					return field.FieldType;
  			}
  			Assert.Fail (name);
  			return null;
  		}
  
  		private MethodDefinition GetMethod (string name)
  		{
  			foreach (MethodDefinition method in type.Methods)
  				if (method.Name == name)
  					return method;
  			Assert.Fail (name);
  			return null;
  		}
  
  		[Test]
  		public void GetMethod ()
  		{
  			Assert.AreSame (GetMethod ("MethodA"), type.GetMethod (new MethodSignature ("MethodA")), "a1");
  
  			Assert.AreSame (GetMethod ("MethodA"), type.GetMethod ("MethodA"), "a2");
  			Assert.AreSame (GetMethod ("MethodA"), type.GetMethod (x => x.Name == "MethodA"), "a3");
  			Assert.AreSame (GetMethod ("MethodA"), type.GetMethod (MethodAttributes.Public, "MethodA"), "a4");
  			Assert.AreSame (GetMethod ("MethodA"), type.GetMethod ("MethodA", "System.Void", new string [1]), "a5");
  			Assert.AreSame (GetMethod ("MethodA"), type.GetMethod (MethodAttributes.Public, "MethodA", "System.Void", new string [1]), "a6");
  			Assert.AreSame (GetMethod ("MethodA"), type.GetMethod (MethodAttributes.Public, "MethodA", "System.Void", new string [1] { "System.Boolean" }, x => x.HasBody), "a7");
  
  			Assert.IsNull (type.GetMethod ("MethodB"), "b1");
  			Assert.IsNull (type.GetMethod (new MethodSignature ("MethodB")), "b2");
  			Assert.IsNull (type.GetMethod (MethodAttributes.Static, "MethodA"), "b3");
  			Assert.IsNull (type.GetMethod ("MethodA", null, new string [0]), "b4");
  			Assert.IsNull (type.GetMethod ("MethodA", "System.Int32", null), "b5");
  			Assert.IsNull (type.GetMethod ("MethodA", null, new string [1] { "System.Int32" }), "b6");
  		}
  
  		[Test]
  		[ExpectedException (typeof (ArgumentNullException))]
  		public void HasAttribute_Null ()
  		{
  			GetType (String.Empty).HasAttribute (null);
  		}
  
  		[Test]
  		public void HasAttribute ()
  		{
  			Assert.IsTrue (GetType (String.Empty).HasAttribute ("NUnit.Framework.TestFixtureAttribute"), "TypeRocksTest");
  			Assert.IsFalse (GetType ("/Enum").HasAttribute ("System.FlagsAttribute"), "Enum/System.FlagsAttribute");
  			Assert.IsTrue (GetType ("/Flags").HasAttribute ("System.FlagsAttribute"), "Flags/System.FlagsAttribute");
  			// fullname is required
  			Assert.IsFalse (GetType ("/Flags").HasAttribute ("System.Flags"), "Flags/System.Flags");
  			Assert.IsFalse (GetType ("/Flags").HasAttribute ("FlagsAttribute"), "Flags/FlagsAttribute");
  		}
  
  		[Test]
  		public void HasMethod ()
  		{
  			Assert.IsTrue (type.HasMethod (new MethodSignature ("MethodA")), "A");
  			Assert.IsFalse (type.HasMethod (new MethodSignature ("MethodB")), "B");
  		}
  
  		[Test]
  
gt: 		[ExpectedException (typeof (ArgumentNullException))]