- observable_property_pattern.zip
- WeakDelegates
- ConsoleTest
- NonPublicTest
- Pvax.WeakDelegates.Tests.nunit
- Pvax.WeakDelegates.Tests
- Pvax.WeakDelegates
- UsubscribeTest
- WeakDelegates.cmbx
- WeakDelegates.FxCop
- WeakDelegates.sln
- WeakDelegates.suo
- WinFormsIdleTest
|
using System;
using System.Drawing;
using NUnit.Framework;
using Pvax.WeakDelegates;
namespace Pvax.WeakDelegates.Tests
{
[TestFixture]
public class TestPointFEvent: TestBase
{
[Test]
public void InstanceToInstanceReflection()
{
eventSource.PointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(eventSource, "PointFEvent", eventSink, "PointFHandler");
eventSink.PointFHandlerCalled = false;
eventSource.OnPointFEvent();
Assert.IsTrue(eventSink.PointFHandlerCalled);
}
[Test]
public void InstanceToInstanceDelegate()
{
eventSource.PointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(eventSource, "PointFEvent", new PointFHandler(eventSink.PointFHandler));
eventSink.PointFHandlerCalled = false;
eventSource.OnPointFEvent();
Assert.IsTrue(eventSink.PointFHandlerCalled);
}
[Test]
public void StaticToInstanceReflection()
{
EventSource.StaticPointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(typeof(EventSource), "StaticPointFEvent", eventSink, "PointFHandler");
eventSink.PointFHandlerCalled = false;
EventSource.OnStaticPointFEvent();
Assert.IsTrue(eventSink.PointFHandlerCalled);
}
[Test]
public void StaticToInstanceDelegate()
{
EventSource.StaticPointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(typeof(EventSource), "StaticPointFEvent", new PointFHandler(eventSink.PointFHandler));
eventSink.PointFHandlerCalled = false;
EventSource.OnStaticPointFEvent();
Assert.IsTrue(eventSink.PointFHandlerCalled);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void InstanceToStaticReflection()
{
eventSource.PointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(eventSource, "PointFEvent", eventSink, "StaticPointFHandler");
eventSource.OnPointFEvent();
Assert.Fail();
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void InstanceToStaticDelegate()
{
eventSource.PointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(eventSource, "PointFEvent", new PointFHandler(EventSink.StaticPointFHandler));
eventSource.OnPointFEvent();
Assert.Fail();
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void StaticToStaticReflection()
{
EventSource.StaticPointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(typeof(EventSource), "PointFEvent", eventSink, "StaticPointFHandler");
EventSource.OnStaticPointFEvent();
Assert.Fail();
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void StaticToStaticDelegate()
{
EventSource.StaticPointFEvent += (PointFHandler)WeakDelegateDecorator.Decorate(typeof(EventSource), "PointFEvent", new PointFHandler(EventSink.StaticPointFHandler));
EventSource.OnStaticPointFEvent();
Assert.Fail();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
I'm a system administrator from Moscow, Russia. Programming is one of my hobbies. I presume I'm one of the first Russians who created a Web site dedicated to .Net known that time as NGWS. However, the Web page has been abandoned a long ago.