Exemplo n.º 1
0
        public void DiscoveryHandlersNeedingDispatcherTest()
        {
            var disp = new CStaticEventHandlersAndDispatcher();
            var disc = new MessageHandlerDiscovery(disp);

            disc.RegisterHandlers(typeof(CStaticEventHandlersAndDispatcher));

            disp.ClearFlags();
            disp.Post(new EvtSquare());

            Assert.AreEqual(true, disp.m_square, "Square");
            Assert.AreEqual(false, disp.m_circle, "Circle");
            Assert.AreEqual(false, disp.m_shape, "Shape");
            Assert.AreEqual(false, disp.m_anything, "Anything");
            Assert.AreEqual(1, disp.Count, "Count");

            disp.ClearFlags();
            disp.Post(new EvtCircle());

            Assert.AreEqual(false, disp.m_square, "Square2");
            Assert.AreEqual(true, disp.m_circle, "Circle2");
            Assert.AreEqual(true, disp.m_shape, "Shape2");
            Assert.AreEqual(false, disp.m_anything, "Anything2");
            Assert.AreEqual(2, disp.Count, "Coutn2");
        }
Exemplo n.º 2
0
        public void ExactValueTest2()
        {
            var dispatcher = new CStaticEventHandlersAndDispatcher();

            dispatcher.RegisterHandler <CStaticEventHandlersAndDispatcher>(EShapes.Square, _disp => _disp.m_square = true);

            dispatcher.ClearFlags();
            dispatcher.Post(EShapes.Circle);
            dispatcher.Post(EShapes.Square);

            Assert.IsTrue(dispatcher.m_square, "m_square");
            Assert.IsFalse(dispatcher.m_circle, "m_circle");
            Assert.IsFalse(dispatcher.m_shape, "m_shape");
            Assert.IsFalse(dispatcher.m_anything, "m_anything");
            Assert.AreEqual(1, dispatcher.EventExecutionCount, "Event Execution Count");
        }
Exemplo n.º 3
0
 public static void HandleSquare(CEventDispatcherTest.EvtSquare _square, CStaticEventHandlersAndDispatcher _dispatcher)
 {
     _dispatcher.Count++;
     _dispatcher.m_square = true;
 }
Exemplo n.º 4
0
        public void X_LambdaRegisrationDispatcherTypeMismatchTest2()
        {
            var disp = new CStaticEventHandlersAndDispatcher();

            disp.RegisterHandler <CBadEventHandler_SecondParamBadDispatcher>(AttributeTargets.Assembly, x => { });
        }
Exemplo n.º 5
0
        public void X_LambdaRegisrationDispatcherTypeMismatchTest()
        {
            var disp = new CStaticEventHandlersAndDispatcher();

            disp.RegisterHandler <int, CBadEventHandler_SecondParamBadDispatcher>((x, y) => { });
        }
Exemplo n.º 6
0
 public static void InvalidDispatcherParam(object _event, CStaticEventHandlersAndDispatcher _shouldBeThisClassOrCEventDispatcher)
 {
 }