public void EventRemove_ByTypes_Private() { var accessor = DelegateFactory.EventRemove <TestClass, TestClass.PrivateEventArgs>("PrivateEvent"); Assert.IsNotNull(accessor); var eventExecuted = false; EventHandler <TestClass.PrivateEventArgs> eventHandler = (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.PrivateEventArgs)); }; _testClassInstance.AddPrivateEventHandler(eventHandler); accessor(_testClassInstance, eventHandler); _testClassInstance.InvokePrivateEvent(); Assert.IsFalse(eventExecuted); }
public void EventRemove_ByObjectAndType_Protected() { var accessor = _testClassType.EventRemove <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 EventRemove_Interface_ByTypes() { var addAccessor = DelegateFactory.EventAdd <IService, EventArgs>("Event"); var removeAccessor = DelegateFactory.EventRemove <IService, EventArgs>("Event"); Assert.IsNotNull(removeAccessor); var eventExecuted = false; EventHandler <EventArgs> eventAction = (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(EventArgs)); }; addAccessor(_interfaceImpl, eventAction); removeAccessor(_interfaceImpl, eventAction); _interfaceImpl.InvokeEvent(); Assert.IsFalse(eventExecuted); }
public void EventRemove_Interface_ByObjects() { var addAccessor = _interfaceType.EventAdd("Event"); var removeAccessor = _interfaceType.EventRemove("Event"); Assert.IsNotNull(removeAccessor); var eventExecuted = false; Action <object, object> eventAction = (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(EventArgs)); }; addAccessor(_interfaceImpl, eventAction); removeAccessor(_interfaceImpl, eventAction); _interfaceImpl.InvokeEvent(); Assert.IsFalse(eventExecuted); }
public void EventRemove_ByObjects_Private() { var addAccessor = _testClassType.EventAdd("PrivateEvent"); var removeAccessor = _testClassType.EventRemove("PrivateEvent"); Assert.IsNotNull(removeAccessor); var eventExecuted = false; Action <object, object> eventAction = (sender, args) => { eventExecuted = true; Assert.IsInstanceOfType(args, typeof(TestClass.PrivateEventArgs)); }; addAccessor(_testClassInstance, eventAction); removeAccessor(_testClassInstance, eventAction); _testClassInstance.InvokePrivateEvent(); Assert.IsFalse(eventExecuted); }