Esempio n. 1
0
        public void Event_Handlers_Should_Work_For_Templates()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow))
            {
                var w = new XamlIlBugTestsEventHandlerCodeBehind();
                w.ApplyTemplate();
                w.Show();

                Dispatcher.UIThread.RunJobs();
                var itemsPresenter = ((ItemsControl)w.Content).GetVisualChildren().FirstOrDefault();
                var item           = itemsPresenter
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First();

                ((Control)item).DataContext = "test";
                Assert.Equal("test", w.SavedContext);
            }
        }
Esempio n. 2
0
        public void Event_Handlers_Should_Work_For_Templates()
        {
            using (UnitTestApplication.Start(TestServices.StyledWindow))
            {
                var w = new XamlIlBugTestsEventHandlerCodeBehind();
                w.ApplyTemplate();
                w.Show();

                Dispatcher.UIThread.RunJobs();
                var itemsPresenter = ((ItemsControl)w.Content).GetVisualChildren().FirstOrDefault();
                var item           = itemsPresenter
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First()
                                     .GetVisualChildren().First();
                ((Control)item).RaiseEvent(new PointerPressedEventArgs {
                    ClickCount = 20
                });
                Assert.Equal(20, w.Args.ClickCount);
            }
        }