예제 #1
0
        public void EventRemove_ByTypes_Public()
        {
            var accessor = DelegateFactory.EventRemove <TestClass, TestClass.PublicEventArgs>("PublicEvent");

            Assert.IsNotNull(accessor);
            var eventExecuted = false;
            EventHandler <TestClass.PublicEventArgs> eventHandler = (sender, args) =>
            {
                eventExecuted = true;
                Assert.IsInstanceOfType(args, typeof(TestClass.PublicEventArgs));
            };

            _testClassInstance.AddPublicEventHandler(eventHandler);
            accessor(_testClassInstance, eventHandler);
            _testClassInstance.InvokePublicEvent();
            Assert.IsFalse(eventExecuted);
        }
예제 #2
0
        public void EventInvoke_ByTypes_Public()
        {
            var call = DelegateFactory.EventInvoke <TestClass, TestClass.PublicEventArgs>("PublicEvent");

            Assert.IsNotNull(call);
            var eventExecuted = false;

            void EventHandler(object sender, TestClass.PublicEventArgs args)
            {
                eventExecuted = true;
                Assert.IsInstanceOfType(args, typeof(TestClass.PublicEventArgs));
            }

            var testClassInstance = new TestClass();

            testClassInstance.AddPublicEventHandler(EventHandler);
            call(testClassInstance, new TestClass.PublicEventArgs());
            Assert.IsTrue(eventExecuted);
        }
예제 #3
0
        public void EventInvoke_ByObjectAndType_EventArgsAsObject()
        {
            var call = typeof(TestClass).EventInvoke <object>("PublicEvent");

            Assert.IsNotNull(call);
            var eventExecuted = false;

            void EventHandler(object sender, TestClass.PublicEventArgs args)
            {
                eventExecuted = true;
                Assert.IsInstanceOfType(args, typeof(TestClass.PublicEventArgs));
            }

            var testClassInstance = new TestClass();

            testClassInstance.AddPublicEventHandler(EventHandler);
            call(testClassInstance, new TestClass.PublicEventArgs());
            Assert.IsTrue(eventExecuted);
        }
        public void EventRemove_ByTypes_Public()
        {
            var accessor = DelegateFactory.EventRemove <TestClass, TestClass.PublicEventArgs>("PublicEvent");

            Assert.IsNotNull(accessor);
            var eventExecuted = false;

            void EventHandler(object sender, TestClass.PublicEventArgs args)
            {
                eventExecuted = true;
                Assert.IsInstanceOfType(args, typeof(TestClass.PublicEventArgs));
            }

            var testClassInstance = new TestClass();

            testClassInstance.AddPublicEventHandler(EventHandler);
            accessor(testClassInstance, EventHandler);
            testClassInstance.InvokePublicEvent();
            Assert.IsFalse(eventExecuted);
        }