Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void SetSiteCacheInterval_WithInvalidValue_ThrowsArgumentException()
        {
            //Arrange
            bool threwException = false;

            var hierarchicalConfig = new SIConfigManager();

            var config = new ServiceLocatorConfig(hierarchicalConfig);

            //Act
            try
            {
                config.SetSiteCacheInterval(-1);
            }
            catch (ArgumentException)
            {
                threwException = true;
            }

            //Assert
            Assert.IsTrue(threwException, "Expected ArgumentException not thrown");
        }