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");
        }