public void Feature_Bindings_shall_requery_if_manager_sends_featurechanged_event()
        {
            Dictionary <string, Feature> Rules = new Dictionary <string, Feature>
            {
                { "One/Two/Three", new Feature(false, false) },
                { "One/Two/TemplatedThree", new Feature(false, false) },
                { "One/Two/Hyperlink", new Feature(false, false) },
            };

            Dictionary <string, Feature> NewRules = new Dictionary <string, Feature>
            {
                { "One/Two/Three", new Feature(true, true) },
                { "One/Two/TemplatedThree", new Feature(true, true) },
                { "One/Two/Hyperlink", new Feature(true, true) },
            };

            TestFeatureSource TestSource        = new TestFeatureSource(Rules);
            TestFeatureSource NewTestSource     = new TestFeatureSource(NewRules);
            IUiFeatureManager FeatureManager    = new UiFeatureManager(new[] { TestSource });
            IUiFeatureManager NewFeatureManager = new UiFeatureManager(new[] { NewTestSource });

            UiFeatureManagementControlTree ControlTree = new UiFeatureManagementControlTree();

            UiFeatureManagement.SetManager(ControlTree, FeatureManager);

            Assert.AreEqual(Visibility.Collapsed, ControlTree.Three.Visibility);
            Assert.AreEqual(Visibility.Collapsed, ControlTree.TemplatedThree.Visibility);
            Assert.IsFalse(ControlTree.Three.IsEnabled);
            Assert.IsFalse(ControlTree.TemplatedThree.IsEnabled);
            Assert.IsFalse(ControlTree.Hyperlink.IsEnabled);

            UiFeatureManagement.SetManager(ControlTree, NewFeatureManager);

            Assert.AreEqual(Visibility.Visible, ControlTree.Three.Visibility);
            Assert.AreEqual(Visibility.Visible, ControlTree.TemplatedThree.Visibility);
            Assert.IsTrue(ControlTree.Three.IsEnabled);
            Assert.IsTrue(ControlTree.TemplatedThree.IsEnabled);
            Assert.IsTrue(ControlTree.Hyperlink.IsEnabled);
        }
        public void Feature_Bindings_shall_query_the_right_contextids()
        {
            Dictionary <string, Feature> Rules = new Dictionary <string, Feature>
            {
                { "One/Two/Three", new Feature(true, false) },
                { "One/Two/TemplatedThree", new Feature(true, false) },
                { "One/Two/OtherThree", new Feature(true, true) },
            };

            TestFeatureSource TestSource     = new TestFeatureSource(Rules);
            IUiFeatureManager FeatureManager = new UiFeatureManager(new[] { TestSource });

            UiFeatureManagementControlTree ControlTree = new UiFeatureManagementControlTree();

            UiFeatureManagement.SetManager(ControlTree, FeatureManager);

            Assert.AreEqual(Visibility.Visible, ControlTree.Three.Visibility);
            Assert.IsFalse(ControlTree.Three.IsEnabled);
            Assert.AreEqual(Visibility.Visible, ControlTree.TemplatedThree.Visibility);
            Assert.IsFalse(ControlTree.TemplatedThree.IsEnabled);
            Assert.AreEqual(Visibility.Visible, ControlTree.OtherThree.Visibility);
            Assert.IsTrue(ControlTree.OtherThree.IsEnabled);
        }
        public void Feature_Bindings_shall_query_the_right_bound_contextids()
        {
            Dictionary <string, Feature> Rules = new Dictionary <string, Feature>
            {
                { "One/Two/BoundThree", new Feature(true, false) },
                { "One/Two/BoundTemplatedThree", new Feature(true, false) },
            };

            TestFeatureSource TestSource     = new TestFeatureSource(Rules);
            IUiFeatureManager FeatureManager = new UiFeatureManager(new[] { TestSource });

            UiFeatureManagementControlTree ControlTree = new UiFeatureManagementControlTree();

            ControlTree.DataContext = new ContextValues("BoundThree");
            ControlTree.Three.SetBinding(UiFeatureManagement.ContextProperty, "Context");
            ControlTree.TemplatedThree.DataContext = new ContextValues("BoundTemplatedThree");
            ControlTree.TemplatedThree.SetBinding(UiFeatureManagement.ContextProperty, "Context");
            UiFeatureManagement.SetManager(ControlTree, FeatureManager);

            Assert.AreEqual(Visibility.Visible, ControlTree.Three.Visibility);
            Assert.AreEqual(Visibility.Visible, ControlTree.TemplatedThree.Visibility);
            Assert.IsFalse(ControlTree.Three.IsEnabled);
            Assert.IsFalse(ControlTree.TemplatedThree.IsEnabled);
        }