diff options
author | jbevain <jbevain@gmail.com> | 2010-04-12 11:19:07 +0400 |
---|---|---|
committer | jbevain <jbevain@gmail.com> | 2010-04-12 11:19:07 +0400 |
commit | 714ac9e6de3606a1f71966ff1684d964d8ae1334 (patch) | |
tree | 1a4d285f4603c8733b1f439acdf66fbc4d40eea5 /Test/Mono.Cecil.Tests/EventTests.cs |
initial commit
Diffstat (limited to 'Test/Mono.Cecil.Tests/EventTests.cs')
-rw-r--r-- | Test/Mono.Cecil.Tests/EventTests.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Test/Mono.Cecil.Tests/EventTests.cs b/Test/Mono.Cecil.Tests/EventTests.cs new file mode 100644 index 0000000..15a599c --- /dev/null +++ b/Test/Mono.Cecil.Tests/EventTests.cs @@ -0,0 +1,66 @@ +using System; + +using Mono.Cecil; +using Mono.Cecil.Metadata; + +using NUnit.Framework; + +namespace Mono.Cecil.Tests { + + [TestFixture] + public class EventTests : BaseTestFixture { + + [TestCSharp ("Events.cs")] + public void AbstractMethod (ModuleDefinition module) + { + var type = module.GetType ("Foo"); + + Assert.IsTrue (type.HasEvents); + + var events = type.Events; + + Assert.AreEqual (1, events.Count); + + var @event = events [0]; + + Assert.IsNotNull (@event); + Assert.AreEqual ("Bar", @event.Name); + Assert.IsNotNull (@event.EventType); + Assert.AreEqual ("Pan", @event.EventType.FullName); + + Assert.IsNotNull (@event.AddMethod); + Assert.AreEqual (MethodSemanticsAttributes.AddOn, @event.AddMethod.SemanticsAttributes); + Assert.IsNotNull (@event.RemoveMethod); + Assert.AreEqual (MethodSemanticsAttributes.RemoveOn, @event.RemoveMethod.SemanticsAttributes); + } + + [TestIL ("others.il")] + public void OtherMethod (ModuleDefinition module) + { + var type = module.GetType ("Others"); + + Assert.IsTrue (type.HasEvents); + + var events = type.Events; + + Assert.AreEqual (1, events.Count); + + var @event = events [0]; + + Assert.IsNotNull (@event); + Assert.AreEqual ("Handler", @event.Name); + Assert.IsNotNull (@event.EventType); + Assert.AreEqual ("System.EventHandler", @event.EventType.FullName); + + Assert.IsTrue (@event.HasOtherMethods); + + Assert.AreEqual (2, @event.OtherMethods.Count); + + var other = @event.OtherMethods [0]; + Assert.AreEqual ("dang_Handler", other.Name); + + other = @event.OtherMethods [1]; + Assert.AreEqual ("fang_Handler", other.Name); + } + } +} |