コード例 #1
0
        public void Execute_ContainsKeyReturnsFalse_WithValidKeyNotSetAtWebAppLevel()
        {
            //arrange
            var    args = new ContainsKeyDataArgs();
            string key  = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName;

            args.Key    = key;
            args.Level  = (int)ConfigLevel.CurrentSPWebApplication;
            args.SiteId = TestsConstants.TestGuid;
            var proxyOp = new ContainsKeyOperation();

            var webApp             = new BSPWebApplication();
            WebAppSettingStore wss = new WebAppSettingStore();
            var webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance);

            MSPSite.ConstructorGuid = (instance, guid) =>
            {
                var site = new MSPSite(instance)
                {
                    WebApplicationGet = () =>
                    {
                        webPO.GetChildString <WebAppSettingStore>((s) => wss);
                        return(webApp);
                    },
                    Dispose = () => { }
                };
            };

            //Act
            var target = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(target, typeof(bool));
            Assert.IsFalse((bool)target);
        }
コード例 #2
0
        public void Execute_ThrowsArgumentNullException_WhenArgsAreNull()
        {
            var proxyOp = new ContainsKeyOperation();

            //Act
            proxyOp.Execute(null);

            //Assert caught by exception...
        }
コード例 #3
0
        public void Execute_ReturnsConfigurationException_WhenWrongArgTypeProvided()
        {
            var proxyOp = new ContainsKeyOperation();
            var args    = new ReadConfigArgs();

            //Act
            object result = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(result, typeof(ConfigurationException));
        }
コード例 #4
0
        public void Execute_ReturnsConfigurationException_WhenSiteIdIsEmpty()
        {
            var proxyOp = new ContainsKeyOperation();
            var args    = new ContainsKeyDataArgs();

            args.Key   = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName;
            args.Level = (int)ConfigLevel.CurrentSPWebApplication;

            //Act
            object result = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(result, typeof(ConfigurationException));
        }
コード例 #5
0
        public void Execute_ReturnsArgumentNullException_WhenKeyIsNull()
        {
            var proxyOp = new ContainsKeyOperation();
            var args    = new ContainsKeyDataArgs();

            args.Key    = null;
            args.SiteId = TestsConstants.TestGuid;
            args.Level  = (int)ConfigLevel.CurrentSPWebApplication;

            //Act
            object result = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(result, typeof(ArgumentNullException));
        }
コード例 #6
0
        public void Execute_ReturnsConfigurationException_WithInvalidLevel()
        {
            //arrange
            var    args    = new ContainsKeyDataArgs();
            string key     = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName;
            var    proxyOp = new ContainsKeyOperation();

            args.Key    = key;
            args.Level  = (int)ConfigLevel.CurrentSPWeb;
            args.SiteId = TestsConstants.TestGuid;

            //Act
            var target = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(target, typeof(ConfigurationException));
        }
コード例 #7
0
        public void Execute_ReturnsAConfigurationException_WhenKeyDoesntHaveNamespace()
        {
            //arrange
            var args = new ContainsKeyDataArgs();

            args.Key    = TestsConstants.TestGuidName;
            args.Level  = (int)ConfigLevel.CurrentSPWebApplication;
            args.SiteId = TestsConstants.TestGuid;

            var proxyOp = new ContainsKeyOperation();

            //Act
            var ex = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(ex, typeof(ConfigurationException));
        }
コード例 #8
0
        public void Execute_ContainsKeyReturnsFalse_WithValidKeyNotSetAtFarmLevel()
        {
            //arrange
            var    args    = new ContainsKeyDataArgs();
            string key     = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName;
            var    proxyOp = new ContainsKeyOperation();
            var    f       = new BSPConfiguredFarm();


            args.Key    = key;
            args.Level  = (int)ConfigLevel.CurrentSPFarm;
            args.SiteId = TestsConstants.TestGuid;

            //Act
            var target = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(target, typeof(bool));
            Assert.IsFalse((bool)target);
        }
コード例 #9
0
        public void Execute_ContainsKeyReturnsTrue_WithValidKeyAtWebAppLevel()
        {
            //arrange
            SPWebAppPropertyBag.ClearCache();
            var    args = new ContainsKeyDataArgs();
            string key  = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName;

            args.Key    = key;
            args.Level  = (int)ConfigLevel.CurrentSPWebApplication;
            args.SiteId = TestsConstants.TestGuid;
            var    proxyOp      = new ContainsKeyOperation();
            string expectedData = "{92700BB6-B144-434F-A97B-5F696068A425}";

            var webApp             = new BSPWebApplication();
            WebAppSettingStore wss = new WebAppSettingStore();
            var webPO = new MSPPersistedObject((SPPersistedObject)webApp.Instance);

            wss.Settings[key] = expectedData;

            MSPSite.ConstructorGuid = (instance, guid) =>
            {
                var site = new MSPSite(instance)
                {
                    WebApplicationGet = () =>
                    {
                        webPO.GetChildString <WebAppSettingStore>((s) => wss);
                        return(webApp);
                    },
                    Dispose = () => { }
                };
            };

            //Act
            var target = proxyOp.Execute(args);

            //Assert .
            Assert.IsInstanceOfType(target, typeof(bool));
            Assert.IsTrue((bool)target);
        }
コード例 #10
0
        public void Execute_ContainsKeyReturnsTrue_WithValidKeyAtFarmLevel()
        {
            //arrange
            SPFarmPropertyBag.ClearCache();
            var    args         = new ContainsKeyDataArgs();
            string key          = ConfigManager.PnPKeyNamespace + "." + TestsConstants.TestGuidName;
            var    proxyOp      = new ContainsKeyOperation();
            var    f            = new BSPConfiguredFarm();
            string expectedData = "{92700BB6-B144-434F-A97B-5F696068A425}";

            args.Key    = key;
            args.Level  = (int)ConfigLevel.CurrentSPFarm;
            args.SiteId = TestsConstants.TestGuid;

            f.SettingStore.Settings[key] = expectedData;

            //Act
            var target = proxyOp.Execute(args);

            //Assert
            Assert.IsInstanceOfType(target, typeof(bool));
            Assert.IsTrue((bool)target);
        }