Esempio n. 1
0
        public void CanSetComponentName()
        {
            string      name      = "Component";
            InComponent component = new InComponent(name);

            Assert.IsTrue(string.Compare(name, component.Name, false) == 0);
        }
Esempio n. 2
0
        public void ComponentHasUniqueId()
        {
            InComponent component1 = new InComponent("Component1");
            InComponent component2 = new InComponent("Component2");

            Assert.IsTrue(component1.Id != component2.Id);
        }
Esempio n. 3
0
            public void CanRegisterPropertyToPropertyRoute()
            {
                Package                 pkg          = new Package();
                OutComponent            outComponent = new OutComponent();
                InComponent             inComponent  = new InComponent();
                PropertyToPropertyRoute route        = PropertyToPropertyRoute.Create(outComponent, x => outComponent.StringOutProperty, inComponent, x => inComponent.StringInProperty);

                pkg.RegisterPropertyRoute(route);
                Assert.IsTrue(pkg.RegisteredPropertyRoutes.Any());

                pkg.UnregisterPropertyRoute(route);
            }
Esempio n. 4
0
            public void CanRegisterEventToPropertyRoute()
            {
                Package              pkg          = new Package();
                OutComponent         outComponent = new OutComponent();
                InComponent          inComponent  = new InComponent();
                EventToPropertyRoute route        = EventToPropertyRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, x => inComponent.TestEventArgsInProperty);

                pkg.RegisterEventRoute(route);
                Assert.IsTrue(pkg.RegisteredEventRoutes.Any());

                pkg.UnregisterEventRoute(route);
            }
Esempio n. 5
0
        public void CanUnregisterPropertyRoute()
        {
            Package               pkg          = new Package();
            OutComponent          outComponent = new OutComponent();
            InComponent           inComponent  = new InComponent();
            PropertyToMethodRoute route        = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x));

            pkg.RegisterPropertyRoute(route);
            pkg.UnregisterPropertyRoute(route);

            Assert.IsTrue(!pkg.RegisteredPropertyRoutes.Any());
        }
Esempio n. 6
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());
        }
Esempio n. 7
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());
            }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public void DuplicatePropertyRoutesDisalllowed()
        {
            Package               pkg          = new Package();
            OutComponent          outComponent = new OutComponent();
            InComponent           inComponent  = new InComponent();
            PropertyToMethodRoute route        = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x));

            pkg.RegisterPropertyRoute(route);
            pkg.RegisterPropertyRoute(route);

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

            pkg.UnregisterPropertyRoute(route);
        }
Esempio n. 10
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());
        }
Esempio n. 11
0
            public void CanCancelEventRouteRegistration()
            {
                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.EventRoutePreRegister += (s, e) =>
                {
                    e.Cancel = true;
                };

                pkg.RegisterEventRoute(route);
                Assert.IsTrue(!pkg.RegisteredEventRoutes.Any());
            }
Esempio n. 12
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);
            }
Esempio n. 13
0
            public void CanAttachToPropertyRouteUnregistered()
            {
                Package               pkg          = new Package();
                OutComponent          outComponent = new OutComponent();
                InComponent           inComponent  = new InComponent();
                PropertyToMethodRoute route        = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x));
                bool caught = false;

                pkg.PropertyRouteUnregistered += (s, e) =>
                {
                    caught = e.PropertyRoute == route;
                };

                pkg.RegisterPropertyRoute(route);
                pkg.UnregisterPropertyRoute(route);

                Assert.IsTrue(caught);
            }
Esempio n. 14
0
            public void CanRegisterPropertyRoute()
            {
                OutComponent outComponent = new OutComponent();
                InComponent  inComponent  = new InComponent();

                PropertyToPropertyRoute route = PropertyToPropertyRoute.Create(outComponent, x => outComponent.IntOutProperty, inComponent, x => inComponent.IntInProperty);

                route.RegisterRoute();

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

                outComponent.IntOutProperty = 100;
                route.UnregisterRoute();

                Assert.AreEqual(outComponent.IntOutProperty, inComponent.IntInProperty);
            }
Esempio n. 15
0
            public void CanCancelPropertyRouteUnregistration()
            {
                Package               pkg          = new Package();
                OutComponent          outComponent = new OutComponent();
                InComponent           inComponent  = new InComponent();
                PropertyToMethodRoute route        = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x));
                bool shouldCancel = true;

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

                pkg.RegisterPropertyRoute(route);
                pkg.UnregisterPropertyRoute(route);
                Assert.IsTrue(pkg.RegisteredPropertyRoutes.Any());
                pkg.UnregisterPropertyRoute(route);
            }
Esempio n. 16
0
            public void CanRegisterPropertyRouteWithReferenceConverter()
            {
                OutComponent outComponent           = new OutComponent();
                InComponent  inComponent            = new InComponent();
                IntToStringRouteConverter converter = new IntToStringRouteConverter();

                PropertyToPropertyRoute route = PropertyToPropertyRoute.Create <string>(outComponent, "IntOutProperty", inComponent, x => inComponent.StringInProperty, converter);

                route.RegisterRoute();

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

                outComponent.IntOutProperty = 100;
                route.UnregisterRoute();

                Assert.IsTrue(string.Compare(outComponent.IntOutProperty.ToString(), inComponent.StringInProperty, false) == 0);
            }
Esempio n. 17
0
            public void CanRegisterPropertyRouteWithValueConverter()
            {
                OutComponent outComponent           = new OutComponent();
                InComponent  inComponent            = new InComponent();
                StringToIntRouteConverter converter = new StringToIntRouteConverter();

                PropertyToPropertyRoute route = PropertyToPropertyRoute.Create <int>(outComponent, "StringOutProperty", inComponent, x => inComponent.IntInProperty, converter);

                route.RegisterRoute();

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

                outComponent.StringOutProperty = "100";
                route.UnregisterRoute();

                Assert.AreEqual(100, inComponent.IntInProperty);
            }
Esempio n. 18
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);
            }
Esempio n. 19
0
            public void CanRegisterEventArgsRouteWithValueConverter()
            {
                OutComponent  outComponent = new OutComponent();
                InComponent   inComponent  = new InComponent();
                TestEventArgs e            = new TestEventArgs("RouteOut", 100);
                TestEventArgsToIntRouteConverter converter = new TestEventArgsToIntRouteConverter();

                EventToPropertyRoute route = EventToPropertyRoute.Create(outComponent, "TestEventOut", inComponent, x => inComponent.IntInProperty, converter);

                route.RegisterRoute();

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

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

                Assert.AreEqual(inComponent.IntInProperty, e.EventInteger);
            }
Esempio n. 20
0
            public void CanRegisterEventArgsRouteWithReferenceConverter()
            {
                OutComponent  outComponent = new OutComponent();
                InComponent   inComponent  = new InComponent();
                TestEventArgs e            = new TestEventArgs("RouteOut", 100);
                TestEventArgsToStringRouteConverter converter = new TestEventArgsToStringRouteConverter();

                EventToMethodRoute route = EventToMethodRoute.Create <string>(outComponent, "TestEventOut", inComponent, (x) => inComponent.StringActionIn(x), converter);

                route.RegisterRoute();

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

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

                Assert.IsTrue(string.Compare(e.EventString, inComponent.StringInProperty, false) == 0);
            }