Xamarin Public Jenkins (auto-signing) 94b2861243 Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
2016-11-10 13:04:39 +00:00

67 lines
1.2 KiB
C#

using System.Linq;
using NUnit.Framework;
using Mono.Cecil.Rocks;
namespace Mono.Cecil.Tests {
[TestFixture]
public class MethodDefinitionRocksTests : BaseTestFixture {
abstract class Foo {
public abstract void DoFoo ();
public abstract void DoBar ();
}
class Bar : Foo {
public override void DoFoo ()
{
}
public override void DoBar ()
{
}
}
class Baz : Bar {
public override void DoFoo ()
{
}
public virtual new void DoBar ()
{
}
}
[Test]
public void GetBaseMethod ()
{
var baz = typeof (Baz).ToDefinition ();
var baz_dofoo = baz.GetMethod ("DoFoo");
var @base = baz_dofoo.GetBaseMethod ();
Assert.AreEqual ("Bar", @base.DeclaringType.Name);
@base = @base.GetBaseMethod ();
Assert.AreEqual ("Foo", @base.DeclaringType.Name);
Assert.AreEqual (@base, @base.GetBaseMethod ());
var new_dobar = baz.GetMethod ("DoBar");
@base = new_dobar.GetBaseMethod();
Assert.AreEqual("Baz", @base.DeclaringType.Name);
}
[Test]
public void GetOriginalBaseMethod ()
{
var baz = typeof (Baz).ToDefinition ();
var baz_dofoo = baz.GetMethod ("DoFoo");
var @base = baz_dofoo.GetOriginalBaseMethod ();
Assert.AreEqual ("Foo", @base.DeclaringType.Name);
}
}
}