Example #1
0
        public void GetSettingFrom_GetASetting_NoKeyReturnsNull()
        {
            //Arrange
            var           hierarchy = new TestablePropertyBagHierarchy();
            BIPropertyBag bag       = GetPropertyBag(ConfigLevel.CurrentSPWeb);

            hierarchy.AddPropertyBag(bag);
            string key    = TestsConstants.TestGuidName;
            var    config = new HierarchicalConfig(hierarchy);
            ConfigurationException configEx = null;

            //Act
            try
            {
                string target = config.GetByKey <string>(key, ConfigLevel.CurrentSPWeb);
            }
            catch (ConfigurationException ex)
            {
                configEx = ex;
            }

            //Assert
            Assert.IsNotNull(configEx);
            Assert.IsTrue(configEx.Message.Contains(key));
        }
Example #2
0
        public void GetByKey_DeSerializeWrongType_ThrowsConfigurationException()
        {
            //Arrange
            var propertyBag = new BIPropertyBag();

            propertyBag.Values.Count = 0;
            string key           = "key";
            string nameSpacedKey = ConfigManager.PnPKeyNamespace + "." + key;
            string expectedError = "SerializationException";

            propertyBag.Values[nameSpacedKey] = "abc";
            var stack = new BIConfigStack();

            stack.Bags.Add(propertyBag);
            string errString = null;

            //Act
            var target = new HierarchicalConfig(stack, new MockConfigSettingSerializer()
            {
                ThrowError = true
            });

            try
            {
                target.GetByKey <DateTime>("key");
            }
            catch (ConfigurationException ex)
            {
                errString = ex.ToString();
            }

            // Assert
            Assert.IsNotNull(errString);
            Assert.IsTrue(errString.Contains(expectedError));
        }
Example #3
0
        public void GetByKey_KeyNotFound_ThrowsConfigurationException()
        {
            // Arrange
            var defaultPropertyBag = new BIPropertyBag();

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

            stack.Bags.Add(defaultPropertyBag);
            bool expectedExceptionThrown = false;

            var target = new HierarchicalConfig(stack);

            //Act
            try
            {
                target.GetByKey <string>("key");
            }
            catch (ConfigurationException)
            {
                expectedExceptionThrown = true;
            }

            // Assert
            Assert.IsTrue(expectedExceptionThrown, "Failed to throw exception on key not found");
        }
 private BIPropertyBag GetPropertyBag(ConfigLevel level)
 {
     var propBag = new BIPropertyBag();
     propBag.Values.Count = 0;
     propBag.Level = level;
     return propBag;
 }
Example #5
0
        public void SetSiteCacheInterval_WithValidValue_UpdatesConfiguration()
        {
            //Arrange
            int    expected    = 30;
            string expectedKey = "Microsoft.Practices.SharePoint.Common.SiteLocatorCacheInterval";
            var    bag         = new BIPropertyBag();
            int    target      = -1;

            var cfgMgr = new SIConfigManager();

            cfgMgr.SetInPropertyBagStringObjectIPropertyBag = (key, value, propBag) =>
            {
                if (key == expectedKey)
                {
                    target = (int)value;
                }
            };
            cfgMgr.GetPropertyBagConfigLevel = (configlevel) => bag;

            var config = new ServiceLocatorConfig(cfgMgr);

            //Act
            config.SetSiteCacheInterval(expected);

            //Assert
            Assert.AreEqual(expected, target);
        }
        public void SerializationFailureThrowsConfigurationException()
        {
            //Arrange
            var propertyBag = new BIPropertyBag();

            propertyBag.Values.Count = 0;
            string errString     = null;
            string expectedError = "SerializationException";
            var    hierarchy     = new BIConfigStack();

            hierarchy.Bags.Add(propertyBag);

            // Act
            var target = new ConfigManager(hierarchy, new MockConfigSettingSerializer()
            {
                ThrowError = true
            });

            try
            {
                target.SetInPropertyBag("key", "MyValue", propertyBag);
            }
            catch (ConfigurationException ex)
            {
                errString = ex.Message;
            }

            // Assert
            Assert.IsNotNull(errString);
            Assert.IsTrue(errString.Contains(expectedError));
        }
Example #7
0
        public void GetSiteCacheInterval_WithoutConfiguredFarmValue_ReturnsNegativeOne()
        {
            //Arrange
            int    expected    = -1;
            string expectedKey = "Microsoft.Practices.SharePoint.Common.SiteLocatorCacheInterval";
            var    bag         = new BIPropertyBag();
            SPFarm farm        = BSPFarm.SetLocal();

            var context = new SIApplicationContextProvider();

            context.GetCurrentAppDomainFriendlyName = () => "FullTrust";
            context.GetSPFarmLocal = () => farm;
            SharePointEnvironment.ApplicationContextProvider = context;

            var configMgr = new SIConfigManager();

            configMgr.ContainsKeyInPropertyBagStringIPropertyBag = (key, propertyBag) =>
            {
                if (key == expectedKey)
                {
                    return(false);
                }
                return(true);
            };
            configMgr.GetPropertyBagConfigLevel = (cfgLevel) => bag;

            var config = new ServiceLocatorConfig(configMgr);

            //Act
            int target = config.GetSiteCacheInterval();

            //Assert
            Assert.AreEqual(expected, target);
        }
Example #8
0
        public void RemoveTypeMappingsGeneric_RemoveAMapping()
        {
            //Arrange
            var typeMappings = new List <TypeMapping> {
                TypeMapping.Create <ILogger, SharePointLogger>(),
                TypeMapping.Create <IConfigManager, ConfigManager>(),
                TypeMapping.Create <IHierarchicalConfig, HierarchicalConfig>()
            };

            var config = new ServiceLocationConfigData(typeMappings);
            var bag    = new BIPropertyBag();

            BSPFarm.SetLocal();
            var cfgMgr = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (key, propertyBag) => true,
                CanAccessFarmConfigGet    = () => true,
                GetPropertyBagConfigLevel = (configlevel) => bag,
            };

            cfgMgr.GetFromPropertyBagStringIPropertyBag <ServiceLocationConfigData>((key, propetyBag) => config);
            cfgMgr.BehaveAsDefaultValue();

            //Act
            var target = new ServiceLocatorConfig(cfgMgr);

            target.RemoveTypeMappings <ILogger>();
            List <TypeMapping> registeredTypeMappings =
                target.GetTypeMappings().ToList();

            //Assert
            Assert.AreEqual(2, registeredTypeMappings.Count);
            Assert.AreSame(typeMappings[1], registeredTypeMappings[0]);
            Assert.AreSame(typeMappings[2], registeredTypeMappings[1]);
        }
        public void Save_AreasConfigurationWithStubs()
        {
            //Arrange
            int saveCount = 0;
            var propBag   = new BIPropertyBag();

            var config = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (key, bag) =>
                {
                    return(false);
                },
                SetInPropertyBagStringObjectIPropertyBag = (key, o, bag) =>
                {
                    if (key == Constants.AreasConfigKey)
                    {
                        saveCount++;
                    }
                },

                GetPropertyBagConfigLevel = (level) => propBag,
            };

            DiagnosticsAreaCollection areas = new DiagnosticsAreaCollection(config);

            //Act
            areas.SaveConfiguration();

            //Assert
            Assert.IsTrue(saveCount == 1);
        }
Example #10
0
        public void RegisterTypeMapping_SetANewMappingForExistingMapping()
        {
            //Arrange
            List <TypeMapping> mappings = null;
            var propertyBag             = new BIPropertyBag();

            BSPFarm.SetLocal();

            var configMgr = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (stringValue, farm) => false,
                SetInPropertyBagStringObjectIPropertyBag   = (strValue, obj, farm) => mappings = obj as List <TypeMapping>,
                CanAccessFarmConfigGet    = () => true,
                GetPropertyBagConfigLevel = (configlevel) => propertyBag
            };

            configMgr.BehaveAsDefaultValue();

            //Act
            var target = new ServiceLocatorConfig(configMgr);

            target.RegisterTypeMapping <ISomething, Something>();
            target.RegisterTypeMapping <ISomething, SomethingElse>();
            TypeMapping mapping = mappings.First();

            //Assert
            Assert.IsTrue(mapping.ToType.Contains("SomethingElse"));
        }
Example #11
0
        public void GetSettingFrom_GetASettingWithHierarchyDoesntFindKey_FromLevelAboveKey()
        {
            //Arrange
            var           hierarchy     = new TestablePropertyBagHierarchy();
            string        key           = TestsConstants.TestGuidName;
            string        namespacedKey = ConfigManager.PnPKeyNamespace + "." + key;
            string        value         = "{80C23A3E-566B-4B11-A881-5868F2BCB198}";
            BIPropertyBag bag           = GetPropertyBag(ConfigLevel.CurrentSPWeb);

            bag.Values[namespacedKey] = value;
            hierarchy.AddPropertyBag(bag);
            hierarchy.AddPropertyBag(GetPropertyBag(ConfigLevel.CurrentSPSite));
            hierarchy.AddPropertyBag(GetPropertyBag(ConfigLevel.CurrentSPWebApplication));
            var target = new HierarchicalConfig(hierarchy);
            ConfigurationException configEx = null;

            //Act
            try
            {
                string result = target.GetByKey <string>(key, ConfigLevel.CurrentSPSite);
            }
            catch (ConfigurationException ex)
            {
                configEx = ex;
            }

            //Assert
            Assert.IsNotNull(configEx);
            Assert.IsTrue(configEx.Message.Contains(key));
        }
Example #12
0
        public void RegisterTypeMapping_SaveNewMappingWithNoContext_ThrowsInvalidOperationException()
        {
            // Arrange
            object value      = null;
            var    rootConfig = new BIPropertyBag();
            bool   expectedExceptionThrown = false;

            var mgr = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (stringValue, propertyBag) => false,
                SetInPropertyBagStringObjectIPropertyBag   = (strValue, obj, propertyBag) => value = obj as List <TypeMapping>,
                GetPropertyBagConfigLevel = (level) => rootConfig,
                CanAccessFarmConfigGet    = () => false
            };

            mgr.GetFromPropertyBagStringIPropertyBag <ServiceLocationConfigData>((key, bag) => null);

            //Act
            var target = new ServiceLocatorConfig(mgr);

            try
            {
                target.RegisterTypeMapping <ISomething, Something>();
            }
            catch (InvalidOperationException)
            {
                expectedExceptionThrown = true;
            }

            Assert.IsTrue(expectedExceptionThrown);
        }
        IPropertyBag GetPropertyBagLevelImpl(ConfigLevel level)
        {
            BIPropertyBag bag = new BIPropertyBag();

            bag.Level        = level;
            bag.Values.Count = 0;
            return(bag);
        }
Example #14
0
        public void RegisterTypeMapping_SaveNewMappingWithSite()
        {
            var    mappings   = new List <TypeMapping>();
            string savedkey   = null;
            object savedValue = null;
            var    configData = new ServiceLocationConfigData(mappings);

            BSPFarm.SetLocal();
            const string expectedKey = "Microsoft.Practices.SharePoint.Common.TypeMappings";
            var          web         = new MSPWeb();
            var          propBag     = new BIPropertyBag();

            var mgr = new SIConfigManager()
            {
                SetInPropertyBagStringObjectIPropertyBag = (key, value, bag) =>
                {
                    savedkey   = key;
                    savedValue = value;
                },

                ContainsKeyInPropertyBagStringIPropertyBag = (key, bag) =>
                {
                    if (key == expectedKey)
                    {
                        return(true);
                    }
                    return(false);
                },
                CanAccessFarmConfigGet    = () => true,
                GetPropertyBagConfigLevel = (level) => propBag,
                SetWebSPWeb = (w) => { },
            };

            mgr.GetFromPropertyBagStringIPropertyBag <ServiceLocationConfigData>((key, bag) =>
            {
                if (key == expectedKey)
                {
                    return(configData);
                }
                return(null);
            });

            var configSite = new MSPSite()
            {
                RootWebGet = () => web
            };

            var target = new ServiceLocatorConfig(mgr);

            target.Site = configSite;

            //act
            target.RegisterTypeMapping <ISomething, Something>();

            //assert
            Assert.IsNotNull(savedValue);
            Assert.AreEqual(expectedKey, savedkey);
        }
        public void CTOR_WithConfigurationMgr_WithoutLogginConfigurationSucceeds()
        {
            //Arrange
            var configMgr = new SIConfigManager();
            var propBag   = new BIPropertyBag();

            configMgr.ContainsKeyInPropertyBagStringIPropertyBag = (key, bag) => false;
            configMgr.GetPropertyBagConfigLevel = (configLevel) => propBag;

            //Act
            var target = new DiagnosticsAreaCollection(configMgr);

            //Assert
            Assert.IsTrue(target.Count == 0);
        }
        public void ContainsKeyInPropertyBagSucceeds()
        {
            //Arrange
            var    bag          = new BIPropertyBag();
            string key          = TestsConstants.TestGuidName;
            string namespaceKey = ConfigManager.PnPKeyNamespace + "." + key;

            bag.Values.SetOne(namespaceKey, "foobar");
            var target = new ConfigManager();

            //Act
            bool expected = target.ContainsKeyInPropertyBag(TestsConstants.TestGuidName, bag);

            //Assert
            Assert.IsTrue(expected);
        }
        public void Add_WithConfigMgrConstructorWithoutConfigData()
        {
            //Arrange
            var configMgr = new SIConfigManager();
            var propBag   = new BIPropertyBag();

            configMgr.ContainsKeyInPropertyBagStringIPropertyBag = (key, bag) => false;
            configMgr.GetPropertyBagConfigLevel = (level) => propBag;

            var target   = new DiagnosticsAreaCollection(configMgr);
            var expected = new DiagnosticsArea(TestsConstants.TestGuidName);

            //Act
            target.Add(expected);

            //Assert
            Assert.AreEqual <DiagnosticsArea>(target[0], expected);
        }
        public void GetFromPropertyBagGenericSucceeds()
        {
            //Arrange
            string key           = TestsConstants.TestGuidName;
            string namespacedKey = ConfigManager.PnPKeyNamespace + "." + key;
            string value         = "{821FC688-2C8C-4F8B-A700-EDB81400B63B}";

            var bag = new BIPropertyBag();

            bag.Values.SetOne(namespacedKey, value);

            //Act
            var    target = new ConfigManager();
            string actual = target.GetFromPropertyBag <string>(key, bag);

            // Assert
            Assert.AreEqual(value, actual);
        }
Example #19
0
        public void ContainsFrom_ContainsASetting_NoKeyReturnsFalse()
        {
            //Arrange
            var           hierarchy = new TestablePropertyBagHierarchy();
            bool          expected  = false;
            BIPropertyBag bag       = GetPropertyBag(ConfigLevel.CurrentSPWeb);

            hierarchy.AddPropertyBag(bag);
            string key = TestsConstants.TestGuidName;

            var config = new HierarchicalConfig(hierarchy);

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

            //Assert
            Assert.AreEqual(expected, target);
        }
Example #20
0
        public void RemoveTypeMapping_RemoveAMapping()
        {
            //Arrange
            var typeMappings = new List <TypeMapping> {
                new TypeMapping()
                {
                    FromAssembly = "1"
                },
                new TypeMapping()
                {
                    FromAssembly = "2"
                },
                new TypeMapping()
                {
                    FromAssembly = "3"
                }
            };
            var config = new ServiceLocationConfigData(typeMappings);
            var bag    = new BIPropertyBag();

            BSPFarm.SetLocal();
            var cfgMgr = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (key, propertyBag) => true,
                CanAccessFarmConfigGet    = () => true,
                GetPropertyBagConfigLevel = (configlevel) => bag,
            };

            cfgMgr.GetFromPropertyBagStringIPropertyBag <ServiceLocationConfigData>((key, propetyBag) => config);
            cfgMgr.BehaveAsDefaultValue();

            //Act
            var target = new ServiceLocatorConfig(cfgMgr);

            target.RemoveTypeMapping(typeMappings[0]);
            List <TypeMapping> registeredTypeMappings =
                target.GetTypeMappings().ToList();

            //Assert
            Assert.AreEqual(2, registeredTypeMappings.Count);
            Assert.AreSame(typeMappings[1], registeredTypeMappings[0]);
            Assert.AreSame(typeMappings[2], registeredTypeMappings[1]);
        }
        public void SaveValueExceedsRetryFails()
        {
            //Arrange
            string key     = "{6313EE1A-5A12-46A3-A537-4905678FBD9E}";
            var    propBag = new BIPropertyBag();
            int    retry   = 0;
            bool   expectedExceptionThrown = false;

            propBag.ItemSetStringString = (k, v) =>
            {
                if (retry < 3)
                {
                    retry++;
                    var ex = new MSPUpdatedConcurrencyException();
                    throw ex.Instance;
                }
                else
                {
                    propBag.Values[k] = v;
                }
            };

            propBag.Values.Count = 0;
            var hierarchy = new BIConfigStack();

            hierarchy.Bags.Add(propBag);
            var target = new ConfigManager(hierarchy, new MockConfigSettingSerializer());

            //Act
            try
            {
                target.SetInPropertyBag(key, 3, propBag);
            }
            catch (ConfigurationException)
            {
                expectedExceptionThrown = true;
            }


            //Assert
            Assert.IsTrue(expectedExceptionThrown);
        }
        public void RemoveKeyFromPropertyBagSucceeds()
        {
            //Arrange
            BIPropertyBag bag           = new BIPropertyBag();
            string        namespacedKey = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName;

            bag.Values.SetOne(namespacedKey, "{821FC688-2C8C-4F8B-A700-EDB81400B63B}");
            var hierarchy = new BIConfigStack();

            hierarchy.Bags.Add(new BIPropertyBag());

            var target = new ConfigManager(hierarchy);

            //Act
            Assert.IsTrue(bag.Values.ContainsKey(namespacedKey));
            target.RemoveKeyFromPropertyBag(TestsConstants.TestGuidName, bag);

            //Assert
            Assert.IsFalse(bag.Values.ContainsKey(namespacedKey));
        }
        public void ContainsKeyInPropertyBagWithNullKeyThrowsArgumentNullException()
        {
            //Arrange
            var  bag    = new BIPropertyBag();
            var  target = new ConfigManager();
            bool expectedExceptionThrown = false;

            //Act
            try
            {
                bool expected = target.ContainsKeyInPropertyBag(null, bag);
            }
            catch (ArgumentNullException)
            {
                expectedExceptionThrown = true;
            }

            //Assert
            Assert.IsTrue(expectedExceptionThrown);
        }
Example #24
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);
        }
        public void SetValueBasedOnKeySucceeds()
        {
            //Arrange
            string key     = "{6313EE1A-5A12-46A3-A537-4905678FBD9E}";
            var    propBag = new BIPropertyBag();

            propBag.Values.Count = 0;
            var hierarchy = new BIConfigStack();

            hierarchy.Bags.Add(propBag);
            var target = new ConfigManager(hierarchy, new MockConfigSettingSerializer());

            //Act
            target.SetInPropertyBag(key, 3, propBag);

            //Assert
            Assert.IsTrue(target.ContainsKeyInPropertyBag(key, propBag));
            int value = target.GetFromPropertyBag <int>(key, propBag);

            Assert.IsTrue(value == 3);
        }
Example #26
0
        public void GetSettingFrom_GetASetting()
        {
            //Arrange
            var           hierarchy = new TestablePropertyBagHierarchy();
            BIPropertyBag bag       = GetPropertyBag(ConfigLevel.CurrentSPSite);

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

            bag.Values[namespacedKey] = expected;
            bag.Level = ConfigLevel.CurrentSPWeb;
            var config = new HierarchicalConfig(hierarchy);

            //Act
            string target = config.GetByKey <string>(key, ConfigLevel.CurrentSPWeb);

            //Assert
            Assert.AreEqual(expected, target);
        }
Example #27
0
        public void GetSiteCacheInterval_WithConfiguredFarmValue_ReturnsValue()
        {
            //Arrange
            int    expected    = 30;
            string expectedKey = "Microsoft.Practices.SharePoint.Common.SiteLocatorCacheInterval";
            var    bag         = new BIPropertyBag();

            BSPFarm.SetLocal();

            var configMgr = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (key, propertyBag) =>
                {
                    if (key == expectedKey)
                    {
                        return(true);
                    }
                    return(false);
                },
                CanAccessFarmConfigGet    = () => true,
                GetPropertyBagConfigLevel = (configlevel) => bag,
            };

            configMgr.GetFromPropertyBagStringIPropertyBag <int>((key, propetyBag) =>
            {
                if (key == expectedKey)
                {
                    return(expected);
                }
                return(-1);
            });

            var config = new ServiceLocatorConfig(configMgr);

            //Act
            int target = config.GetSiteCacheInterval();

            //Assert
            Assert.AreEqual(expected, target);
        }
        public void SetConfigValueLogs()
        {
            //Arrange
            var propertyBag = new BIPropertyBag();

            propertyBag.Values.Count = 0;
            var    farm      = new BSPFarm();
            string key       = "myKey";
            string value     = "myValue";
            var    hierarchy = new BIConfigStack();

            hierarchy.Bags.Add(propertyBag);

            //Act
            var target = new ConfigManager(hierarchy);

            target.SetInPropertyBag(key, value, target.GetPropertyBag(ConfigLevel.CurrentSPFarm));

            //Assert
            StringAssert.Contains(logger.TraceMessage, key);
            StringAssert.Contains(logger.TraceMessage, value);
        }
Example #29
0
        public void RegisterTypeMapping_SaveNewMapping()
        {
            // Arrange
            object value      = null;
            var    rootConfig = new BIPropertyBag();

            BSPFarm.SetLocal();

            var mgr = new SIConfigManager
            {
                ContainsKeyInPropertyBagStringIPropertyBag = (stringValue, propertyBag) => false,
                SetInPropertyBagStringObjectIPropertyBag   = (strValue, obj, propertyBag) => value = obj as List <TypeMapping>,
                GetPropertyBagConfigLevel = (level) => rootConfig,
                CanAccessFarmConfigGet    = () => true
            };

            mgr.GetFromPropertyBagStringIPropertyBag <ServiceLocationConfigData>((key, bag) => null);

            //Act
            var target = new ServiceLocatorConfig(mgr);

            target.RegisterTypeMapping <ISomething, Something>();
            var typeMappings = value as List <TypeMapping>;


            //Assert
            Assert.IsNotNull(typeMappings);
            Assert.IsTrue(typeMappings.Count >= 1);
            TypeMapping mapping = typeMappings[0];

            Assert.AreEqual("Microsoft.Practices.SharePoint.Common.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                            , mapping.FromAssembly);
            Assert.AreEqual("Microsoft.Practices.SharePoint.Common.Tests.ServiceLocation.ISomething, Microsoft.Practices.SharePoint.Common.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                            , mapping.FromType);
            Assert.AreEqual("Microsoft.Practices.SharePoint.Common.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                            , mapping.ToAssembly);
            Assert.AreEqual("Microsoft.Practices.SharePoint.Common.Tests.ServiceLocation.Something, Microsoft.Practices.SharePoint.Common.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
                            , mapping.ToType);
        }
Example #30
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));
        }