Exemplo n.º 1
0
        public void KeyExistsWillUseHierarchy()
        {
            MockPropertyBag parent = BuildPropertyBagHierarcy();

            var target = new HierarchicalConfig(parent.Children.First());

            Assert.IsFalse(target.ContainsKey("value"));

            parent["value"] = "value";

            Assert.IsTrue(target.ContainsKey("value"));
        }
Exemplo n.º 2
0
        public void ContainsKey_ContainsWithHierarchy()
        {
            //Arrange
            var    parent       = new BIPropertyBag();
            var    child        = new BIPropertyBag();
            string key          = "value";
            string namespaceKey = ConfigManager.PnPKeyNamespace + "." + key;

            parent.Values.Count = 0;
            child.Values.Count  = 0;
            var stack = new BIConfigStack();

            stack.Bags.Add(child);
            stack.Bags.Add(parent);

            //Act, Assert
            var          target    = new HierarchicalConfig(stack);
            IPropertyBag parentBag = parent;

            Assert.IsFalse(target.ContainsKey("value"));
            parentBag[namespaceKey] = null;
            Assert.IsTrue(target.ContainsKey(key));
        }
Exemplo n.º 3
0
        public void ContainsFrom_ContainsASettingWithHierarchy_NoKeyReturnsFalse()
        {
            //Arrange
            var    hierarchy = new TestablePropertyBagHierarchy();
            string key       = TestsConstants.TestGuidName;
            bool   expected  = false;

            hierarchy.AddPropertyBag(GetPropertyBag(ConfigLevel.CurrentSPWeb));
            hierarchy.AddPropertyBag(GetPropertyBag(ConfigLevel.CurrentSPSite));
            var config = new HierarchicalConfig(hierarchy);

            //Act
            bool target = config.ContainsKey(key, ConfigLevel.CurrentSPWeb);

            //Assert
            Assert.AreEqual(expected, target);
        }
Exemplo n.º 4
0
        public void ContainsFrom_ContainsASetting_WithNullKeyThrowsArgumentNullException()
        {
            //Arrange
            bool expectedExceptionThrown = false;
            var  hierarchy = new TestablePropertyBagHierarchy();
            var  config    = new HierarchicalConfig(hierarchy);

            //Act
            try
            {
                config.ContainsKey(null, ConfigLevel.CurrentSPSite);
            }
            catch (ArgumentNullException)
            {
                expectedExceptionThrown = true;
            }

            Assert.IsTrue(expectedExceptionThrown);
        }
Exemplo n.º 5
0
        public void ContainsFrom_ContainsASetting()
        {
            //Arrange
            var           hierarchy = new TestablePropertyBagHierarchy();
            bool          expected  = true;
            BIPropertyBag bag       = GetPropertyBag(ConfigLevel.CurrentSPWeb);

            hierarchy.AddPropertyBag(bag);
            string key           = TestsConstants.TestGuidName;
            string namespacedKey = ConfigManager.PnPKeyNamespace + "." + key;
            string value         = "{80C23A3E-566B-4B11-A881-5868F2BCB198}";

            bag.Values[namespacedKey] = value;
            var config = new HierarchicalConfig(hierarchy);

            //Act
            bool target = config.ContainsKey(key, ConfigLevel.CurrentSPWeb);

            //Assert
            Assert.AreEqual(expected, target);
        }