Ejemplo n.º 1
0
        public void CanUnregisterEventRoute()
        {
            Package            pkg          = new Package();
            OutComponent       outComponent = new OutComponent();
            InComponent        inComponent  = new InComponent();
            EventToMethodRoute route        = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x));

            pkg.RegisterEventRoute(route);
            pkg.UnregisterEventRoute(route);

            Assert.IsTrue(!pkg.RegisteredEventRoutes.Any());
        }
Ejemplo n.º 2
0
        public void DuplicateEventRoutesDisalllowed()
        {
            Package            pkg          = new Package();
            OutComponent       outComponent = new OutComponent();
            InComponent        inComponent  = new InComponent();
            EventToMethodRoute route        = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x));

            pkg.RegisterEventRoute(route);
            pkg.RegisterEventRoute(route);

            Assert.AreEqual(pkg.RegisteredEventRoutes.Count(), 1);

            pkg.UnregisterEventRoute(route);
        }
Ejemplo n.º 3
0
            public void CanCancelEventRouteUnregistration()
            {
                Package            pkg          = new Package();
                OutComponent       outComponent = new OutComponent();
                InComponent        inComponent  = new InComponent();
                EventToMethodRoute route        = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x));
                bool shouldCancel = true;

                pkg.EventRoutePreUnregister += (s, e) =>
                {
                    e.Cancel     = shouldCancel;
                    shouldCancel = false;
                };

                pkg.RegisterEventRoute(route);
                pkg.UnregisterEventRoute(route);
                Assert.IsTrue(pkg.RegisteredEventRoutes.Any());
                pkg.UnregisterEventRoute(route);
            }
Ejemplo n.º 4
0
        public void CanUnregisterAllRoutes()
        {
            Package               pkg          = new Package();
            OutComponent          outComponent = new OutComponent();
            InComponent           inComponent  = new InComponent();
            EventToMethodRoute    eRoute       = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x));
            PropertyToMethodRoute pRoute       = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x));

            pkg.RegisterEventRoute(eRoute);
            pkg.RegisterPropertyRoute(pRoute);

            pkg.UnregisterAll();

            Assert.IsTrue(!pkg.RegisteredEventRoutes.Any() & !pkg.RegisteredPropertyRoutes.Any());
        }
Ejemplo n.º 5
0
            public void CanAttachToEventRouteUnregistered()
            {
                Package            pkg          = new Package();
                OutComponent       outComponent = new OutComponent();
                InComponent        inComponent  = new InComponent();
                EventToMethodRoute route        = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x));
                bool caught = false;

                pkg.EventRouteUnregistered += (s, e) =>
                {
                    caught = e.EventRoute == route;
                };

                pkg.RegisterEventRoute(route);
                pkg.UnregisterEventRoute(route);

                Assert.IsTrue(caught);
            }
Ejemplo n.º 6
0
            public void ComponentsRegistration()
            {
                Package            pkg          = new Package();
                OutComponent       outComponent = new OutComponent();
                InComponent        inComponent  = new InComponent();
                EventToMethodRoute route        = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x));

                pkg.RegisterEventRoute(route);
                Assert.AreEqual <int>(2, pkg.Components.Count());

                pkg.UnregisterEventRoute(route);
                Assert.AreEqual <int>(0, pkg.Components.Count());
            }
Ejemplo n.º 7
0
            public void CanRegisterEventArgsRoute()
            {
                OutComponent  outComponent = new OutComponent();
                InComponent   inComponent  = new InComponent();
                TestEventArgs e            = new TestEventArgs("RouteOut", 100);

                EventToMethodRoute route = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x));

                route.RegisterRoute();

                if (!route.IsRegistered)
                {
                    Assert.Fail("Route not registered.");
                }

                outComponent.RaiseTestEventOut(e);
                route.UnregisterRoute();

                Assert.AreEqual(inComponent.IntInProperty, e.EventInteger);
            }