public void UserRoutedEvent_routed_event_handle_test()
        {
            var autoResetEvent = new AutoResetEvent(false);

            RoutedEventArgs <User> actualRoutedEventArgs = new RoutedEventArgs <User>()
            {
                Parameter = new User()
                {
                    Id = Guid.NewGuid().ToString(), Name = "Test"
                }
            };

            var routedEventContainer = Application.Current.Container.Resolve <IRoutedEventContainer>();
            RoutedEventSender      expectedRoutedEventSender = null;
            RoutedEventArgs <User> expectedRoutedEventArgs   = null;

            routedEventContainer.AddHandler(TestRoutedEvents.UserRoutedEvent, (sender, args) =>
            {
                expectedRoutedEventSender = sender;
                expectedRoutedEventArgs   = args;
                autoResetEvent.Set();
            });

            routedEventContainer.Raise(TestRoutedEvents.UserRoutedEvent, this, actualRoutedEventArgs);

            autoResetEvent.WaitOne(5000);

            Assert.IsNotNull(expectedRoutedEventSender);
            Assert.IsNotNull(expectedRoutedEventArgs);

            Assert.AreEqual(expectedRoutedEventArgs.Parameter.Id, actualRoutedEventArgs.Parameter.Id);
        }
Ejemplo n.º 2
0
        public void SimpleRoutedEvent_routed_event_handle_test()
        {
            var autoResetEvent = new AutoResetEvent(false);

            var routedEventContainer = Application.Current.Container.Resolve <IRoutedEventContainer>();
            RoutedEventSender expectedRoutedEventSender = null;
            RoutedEventArgs   expectedRoutedEventArgs   = null;

            routedEventContainer.AddHandler(TestRoutedEvents.SimpleRoutedEvent, (sender, args) =>
            {
                expectedRoutedEventSender = sender;
                expectedRoutedEventArgs   = args;
                autoResetEvent.Set();
            });

            routedEventContainer.Raise(TestRoutedEvents.SimpleRoutedEvent, this, RoutedEventArgs.Empty);

            autoResetEvent.WaitOne(5000);

            Assert.IsNotNull(expectedRoutedEventSender);
            Assert.IsNotNull(expectedRoutedEventArgs);

            Assert.IsNotNull(expectedRoutedEventSender);
            Assert.IsTrue(expectedRoutedEventArgs.GetType() == typeof(RoutedEventArgs));
        }
        public RoutedEventMessage(RoutedEventBase routedEvent, RoutedEventSender sender, object args)
        {
            Preconditions.CheckNotNull(routedEvent, "routedEvent");
            Preconditions.CheckNotNull(sender, "sender");

            RoutedEventName = routedEvent.Name;
            Sender          = sender;
            Args            = args;
        }
        public RoutedEventMessage(RoutedEventBase routedEvent, RoutedEventSender sender, object args)
        {
            Preconditions.CheckNotNull(routedEvent, "routedEvent");
            Preconditions.CheckNotNull(sender, "sender");

            RoutedEventName = routedEvent.Name;
            Sender = sender;
            Args = args;
        }