PageRenderTime 20ms CodeModel.GetById 9ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/Mono.Cecil/rocks/Test/Mono.Cecil.Tests/MethodDefinitionRocksTests.cs

http://github.com/icsharpcode/ILSpy
C# | 53 lines | 40 code | 13 blank | 0 comment | 0 complexity | ea12b0311a07c9368370b9cfca928fa0 MD5 | raw file
 1using System.Linq;
 2
 3using NUnit.Framework;
 4
 5using Mono.Cecil.Rocks;
 6
 7namespace Mono.Cecil.Tests {
 8
 9	[TestFixture]
10	public class MethodDefinitionRocksTests : BaseTestFixture {
11
12		abstract class Foo {
13			public abstract void DoFoo ();
14		}
15
16		class Bar : Foo {
17			public override void DoFoo ()
18			{
19			}
20		}
21
22		class Baz : Bar {
23			public override void DoFoo ()
24			{
25			}
26		}
27
28		[Test]
29		public void GetBaseMethod ()
30		{
31			var baz = typeof (Baz).ToDefinition ();
32			var baz_dofoo = baz.GetMethod ("DoFoo");
33
34			var @base = baz_dofoo.GetBaseMethod ();
35			Assert.AreEqual ("Bar", @base.DeclaringType.Name);
36
37			@base = @base.GetBaseMethod ();
38			Assert.AreEqual ("Foo", @base.DeclaringType.Name);
39
40			Assert.AreEqual (@base, @base.GetBaseMethod ());
41		}
42
43		[Test]
44		public void GetOriginalBaseMethod ()
45		{
46			var baz = typeof (Baz).ToDefinition ();
47			var baz_dofoo = baz.GetMethod ("DoFoo");
48
49			var @base = baz_dofoo.GetOriginalBaseMethod ();
50			Assert.AreEqual ("Foo", @base.DeclaringType.Name);
51		}
52	}
53}