Example #1
0
        public void Wrap_TListener_T005()
        {
            var test = new EventTestContext();

            Assert.ThrowsException <ArgumentException>(
                () => Wrapper.Wrap <EventRaiser>(test.Listener.HandleRaised));
        }
Example #2
0
        public void Wrap_TListener_T003()
        {
            var test = new EventTestContext();

            test.Raiser.Raised += Wrapper.Wrap <EventListener>(test.Listener.HandleRaised);

            test.Raiser.Raise();

            Assert.IsTrue(test.Result.RaisedCalled);
        }
Example #3
0
        public void Wrap_TArgs_TListener_T003()
        {
            var test = new EventTestContext();

            test.Raiser.RaisedId += Wrapper.Wrap <RaisedIdEventArgs, EventListener>(
                test.Listener.HandleRaisedId);

            test.Raiser.RaiseId(1);

            Assert.IsTrue(test.Result.RaisedIdCalled);
        }
Example #4
0
        public void Wrap_TArgs_TListener_T006()
        {
            var test = new EventTestContext();

            const int Id = 1;

            EventHandler <RaisedIdEventArgs> handler = (sender, e) => Assert.AreEqual(Id, e.Id);

            test.Raiser.RaisedId += Wrapper.Wrap <RaisedIdEventArgs, EventListener>(handler);

            test.Raiser.RaiseId(Id);
        }
Example #5
0
        public void Wrap_TListener_T004()
        {
            var test = new EventTestContext();

            test.Raiser.Raised += Wrapper.Wrap <EventListener>(
                test.Listener.HandleRaised);

            test.Listener = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            Assert.IsFalse(test.Result.RaisedCalled);
        }
Example #6
0
        public void Wrap_T001()
        {
            var test = new EventTestContext();

            Assert.ThrowsException <ArgumentNullException>(() =>
            {
                IdWrapper.Register <EventRaiser, EventListener>(test.Raiser,
                                                                (d, eh) => d.RaisedId += eh,
                                                                (d, eh) => d.RaisedId -= eh,
                                                                test.Listener,
                                                                null
                                                                );
            });
        }
Example #7
0
        public void WrapInReflectionCall_TArgs_T003()
        {
            var test = new EventTestContext();

            IdWrapper.Register <EventRaiser, EventListener>(test.Raiser,
                                                            (d, eh) => d.RaisedId += eh,
                                                            (d, eh) => d.RaisedId -= eh,
                                                            test.Listener,
                                                            (me, sender, args) => me.HandleRaisedId(sender, args)
                                                            );
            //test.Raiser.RaisedId += test.Listener.HandleRaisedId;

            test.Raiser.RaiseId(1);

            Assert.IsTrue(test.Result.RaisedIdCalled);
        }
Example #8
0
        public void Wrap_T003()
        {
            var test = new EventTestContext();

            Wrapper.Register <EventRaiser, EventListener>(test.Raiser,
                                                          (d, eh) => d.Raised += eh,
                                                          (d, eh) => d.Raised -= eh,
                                                          test.Listener,
                                                          (me, sender, args) => me.HandleRaised(sender, args)
                                                          );
            //test.Raiser.Raised += test.Listener.HandleRaised;

            test.Raiser.Raise();

            Assert.IsTrue(test.Result.RaisedCalled);
        }
Example #9
0
        public void WrapInReflectionCall_TArgs_T005()
        {
            var test = new EventTestContext();

            const int Id = 1;

            Action <EventListener, object, RaisedIdEventArgs> handler = (me, sender, e) => Assert.AreEqual(Id, e.Id);

            IdWrapper.Register <EventRaiser, EventListener>(test.Raiser,
                                                            (d, eh) => d.RaisedId += eh,
                                                            (d, eh) => d.RaisedId -= eh,
                                                            test.Listener,
                                                            handler
                                                            );
            //test.Raiser.RaisedId += handler;

            test.Raiser.RaiseId(Id);
        }
Example #10
0
        public void WrapInReflectionCall_TArgs_T004()
        {
            var test = new EventTestContext();

            IdWrapper.Register <EventRaiser, EventListener>(test.Raiser,
                                                            (d, eh) => d.RaisedId += eh,
                                                            (d, eh) => d.RaisedId -= eh,
                                                            test.Listener,
                                                            (me, sender, args) => me.HandleRaisedId(sender, args)
                                                            );
            //test.Raiser.RaisedId += test.Listener.HandleRaisedId;

            test.Listener = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            test.Raiser.RaiseId(1);

            Assert.IsFalse(test.Result.RaisedIdCalled);
        }