public void VerifyDataContextOfDirectChildOfGridViewItemWithNullDataContext()
        {
            var gridViewItem = new GridViewItem();

            AutomationProperties.SetName(gridViewItem, "Windows.UI.Xaml.Controls.Button");
            var content = new Button()
            {
                DataContext = new Button()
            };

            gridViewItem.Content     = content;
            gridViewItem.DataContext = null;

            App.Content = gridViewItem;

            var directChild = VisualTreeHelper.GetChild(gridViewItem, 0) as FrameworkElement;

            directChild.DataContext = null;
            directChild             = VisualTreeHelper.GetChild(directChild, 0) as FrameworkElement;
            directChild.DataContext = null;

            var peer = FrameworkElementAutomationPeer.CreatePeerForElement(gridViewItem);

            var rule = new ListItemNameNotEqualDataContextRule();

            Assert.IsTrue(rule.IsValid(gridViewItem, peer));
        }
        public void VerifyDataContextOfDirectChildOfListViewItem()
        {
            var listViewItem = new ListViewItem();

            AutomationProperties.SetName(listViewItem, "Windows.UI.Xaml.Controls.Button");
            var content = new Button()
            {
                DataContext = new Button()
            };

            listViewItem.Content     = content;
            listViewItem.DataContext = null;
            var peer = FrameworkElementAutomationPeer.CreatePeerForElement(listViewItem);

            App.Content = listViewItem;

            var rule = new ListItemNameNotEqualDataContextRule();

            Assert.IsFalse(rule.IsValid(listViewItem, peer));
        }