Inheritance: IEvent
Ejemplo n.º 1
0
        public void TestCase()
        {
            // create the event aggregator and the objects
            // that contains the handler methods
            var aggr = new EventAggregator();

            var handlerObj1 = new TestHandlers();
            var handlerObj2 = new TestHandlers();

            aggr.Register(handlerObj1);
            aggr.Register(handlerObj2);

            // create some mock events and set their sample values
            var evt1 = new Event1(); evt1.Foo = 1337;
            var evt2 = new Event2(); evt2.Bar = "Hello";

            // trigger the events: 1st time
            aggr.Trigger(evt1);
            aggr.Trigger(evt2);

            Assert.IsTrue(handlerObj1.GotEvt1);
            Assert.AreEqual(handlerObj1.Evt1Data, 1337);

            Assert.IsTrue(handlerObj2.GotEvt1);
            Assert.AreEqual(handlerObj2.Evt1Data, 1337);

            Assert.IsTrue(handlerObj1.GotEvt2);
            Assert.AreEqual(handlerObj1.Evt2Data, "Hello");

            Assert.IsTrue(handlerObj2.GotEvt2);
            Assert.AreEqual(handlerObj2.Evt2Data, "Hello");

            // prepare the handlers for the next test
            handlerObj1.Reset();
            handlerObj2.Reset();

            evt1.Foo = 42;
            evt2.Bar = "Blubb";

            // trigger the events: 2st time
            aggr.Trigger(evt2);
            aggr.Trigger(evt1);


            Assert.IsTrue(handlerObj1.GotEvt1);
            Assert.AreEqual(handlerObj1.Evt1Data, 42);

            Assert.IsTrue(handlerObj2.GotEvt1);
            Assert.AreEqual(handlerObj2.Evt1Data, 42);

            Assert.IsTrue(handlerObj1.GotEvt2);
            Assert.AreEqual(handlerObj1.Evt2Data, "Blubb");

            Assert.IsTrue(handlerObj2.GotEvt2);
            Assert.AreEqual(handlerObj2.Evt2Data, "Blubb");
        }
Ejemplo n.º 2
0
        public void TestCase()
        {
            // create the event aggregator and the objects
            // that contains the handler methods
            var aggr = new EventAggregator();

            var handlerObj1 = new TestHandlers();
            var handlerObj2 = new TestHandlers();

            aggr.Register(handlerObj1);
            aggr.Register(handlerObj2);

            // create some mock events and set their sample values
            var evt1 = new Event1(); evt1.Foo = 1337;
            var evt2 = new Event2(); evt2.Bar = "Hello";

            // trigger the events: 1st time
            aggr.Trigger(evt1);
            aggr.Trigger(evt2);

            Assert.IsTrue(handlerObj1.GotEvt1);
            Assert.AreEqual(handlerObj1.Evt1Data, 1337);

            Assert.IsTrue(handlerObj2.GotEvt1);
            Assert.AreEqual(handlerObj2.Evt1Data, 1337);

            Assert.IsTrue(handlerObj1.GotEvt2);
            Assert.AreEqual(handlerObj1.Evt2Data, "Hello");

            Assert.IsTrue(handlerObj2.GotEvt2);
            Assert.AreEqual(handlerObj2.Evt2Data, "Hello");

            // prepare the handlers for the next test
            handlerObj1.Reset();
            handlerObj2.Reset();

            evt1.Foo = 42;
            evt2.Bar = "Blubb";

            // trigger the events: 2st time
            aggr.Trigger(evt2);
            aggr.Trigger(evt1);

            Assert.IsTrue(handlerObj1.GotEvt1);
            Assert.AreEqual(handlerObj1.Evt1Data, 42);

            Assert.IsTrue(handlerObj2.GotEvt1);
            Assert.AreEqual(handlerObj2.Evt1Data, 42);

            Assert.IsTrue(handlerObj1.GotEvt2);
            Assert.AreEqual(handlerObj1.Evt2Data, "Blubb");

            Assert.IsTrue(handlerObj2.GotEvt2);
            Assert.AreEqual(handlerObj2.Evt2Data, "Blubb");
        }
Ejemplo n.º 3
0
 public void OnEvent1(Event1 evt)
 {
     GotEvt1  = true;
     Evt1Data = evt.Foo;
 }
Ejemplo n.º 4
0
 public void OnEvent1(Event1 evt)
 {
     GotEvt1 = true;
     Evt1Data = evt.Foo;
 }