Ejemplo n.º 1
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);
            }
Ejemplo n.º 2
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);
            }
Ejemplo n.º 3
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);
            }
Ejemplo n.º 4
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);
            }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            PublisherComponent      publisher  = new PublisherComponent();
            SubscriberComponent     subscriber = new SubscriberComponent();
            PropertyToPropertyRoute route      = PropertyToPropertyRoute.Create(publisher, x => publisher.DateTime, subscriber, x => subscriber.DateTime, new StringToDateTimeRouteConverter());
            Package package = new Package();

            package.RegisterPropertyRoute(route);

            for (int i = 0; i < 10; i++)
            {
                publisher.DateTime = DateTimeOffset.Now.Add(new TimeSpan(i, 0, 0, 0, 0)).ToString();
                Console.WriteLine(subscriber.DateTime);
            }

            package.UnregisterAll();

            Console.WriteLine();
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }