Ejemplo n.º 1
0
        public virtual void SelectionCallsOnChanged()
        {
            foreach (IOverriddenTreeView overriddenTreeView in OverriddenTreeViewsToTest)
            {
                TreeView view = overriddenTreeView as TreeView;
                if (view == null)
                {
                    continue;
                }

                TreeViewItem first = new TreeViewItem {
                    Header = "First"
                };
                TreeViewItem second = new TreeViewItem {
                    Header = "Second"
                };
                view.Items.Add(first);
                view.Items.Add(second);
                MethodCallMonitor monitor = overriddenTreeView.SelectedItemChangedActions.CreateMonitor();

                TestTaskAsync(
                    view,
                    () =>
                {
                    monitor.Reset();
                    first.IsSelected = true;
                    monitor.AssertCalled("OnSelectedItemChanged was not called when selecting the first item!");
                },
                    () =>
                {
                    monitor.Reset();
                    second.IsSelected = true;
                    monitor.AssertCalled("OnSelectedItemChanged was not called when selecting the second item!");
                },
                    () => Assert.IsFalse(first.IsSelected, "The first item should no longer be selected!"),
                    () =>
                {
                    monitor.Reset();
                    second.IsSelected = false;
                    monitor.AssertCalled("OnSelectedItemChanged was not called when unselecting the second item!");
                });
            }

            EnqueueTestComplete();
        }
        public virtual void ChangingHeaderCallsOnHeaderTemplateChanged()
        {
            foreach (IOverriddenHeaderedItemsControl overriddenItem in OverriddenHeaderedItemsControlsToTest)
            {
                HeaderedItemsControl control = overriddenItem as HeaderedItemsControl;
                MethodCallMonitor monitor = overriddenItem.HeaderTemplateChangedActions.CreateMonitor();

                TestTaskAsync(
                    control,
                    () =>
                    {
                        control.HeaderTemplate = new DataTemplate();
                        monitor.AssertCalled("OnHeaderTemplateChanged was not called when changing the header template!");
                    });
            }

            EnqueueTestComplete();
        }