public void EventRemove_ByTypes_Protected() { var accessor = DelegateFactory.EventRemove <TestClass, TestClass.ProtectedEventArgs>("ProtectedEvent"); Assert.IsNotNull(accessor); var eventExecuted = false; EventHandler <TestClass.ProtectedEventArgs> eventHandler = (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.ProtectedEventArgs)); }; _testClassInstance.AddProtectedEventHandler(eventHandler); accessor(_testClassInstance, eventHandler); _testClassInstance.InvokeProtectedEvent(); Assert.IsFalse(eventExecuted); }
public void EventInvoke_ByTypes_Protected() { var call = DelegateFactory.EventInvoke <TestClass, TestClass.ProtectedEventArgs>("ProtectedEvent"); Assert.IsNotNull(call); var eventExecuted = false; void EventHandler(object sender, TestClass.ProtectedEventArgs args) { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.ProtectedEventArgs)); } var testClassInstance = new TestClass(); testClassInstance.AddProtectedEventHandler(EventHandler); call(testClassInstance, new TestClass.ProtectedEventArgs()); Assert.IsTrue(eventExecuted); }
public void EventRemove_ByTypes_Protected() { var accessor = DelegateFactory.EventRemove <TestClass, TestClass.ProtectedEventArgs>("ProtectedEvent"); Assert.IsNotNull(accessor); var eventExecuted = false; void EventHandler(object sender, TestClass.ProtectedEventArgs args) { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.ProtectedEventArgs)); } var testClassInstance = new TestClass(); testClassInstance.AddProtectedEventHandler(EventHandler); accessor(testClassInstance, EventHandler); testClassInstance.InvokeProtectedEvent(); Assert.IsFalse(eventExecuted); }