Ejemplo n.º 1
0
        public void TokenProviderCanBeDisabled()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                var _mockProvider = new Provider
                {
                    Assembly      = "OfficeDevPnP.Core.Tests",
                    Type          = "OfficeDevPnP.Core.Tests.Framework.ExtensibilityCallOut.ExtensibilityMockTokenProvider",
                    Configuration = ExtensibilityTestConstants.PROVIDER_MOCK_DATA,
                    Enabled       = false
                };

                var provisioningInfo = new ProvisioningTemplateApplyingInformation();
                provisioningInfo.HandlersToProcess = Handlers.All;
                provisioningInfo.ExtensibilityHandlers.Add(_mockProvider);

                var _mockTemplate = new ProvisioningTemplate();
                _mockTemplate.Id = ExtensibilityTestConstants.PROVISIONINGTEMPLATE_ID;
                _mockTemplate.ExtensibilityHandlers.Add(_mockProvider);

                var extensibilityHandler = new ObjectExtensibilityHandlers();
                var parser = new TokenParser(ctx.Web, _mockTemplate);
                extensibilityHandler.AddExtendedTokens(ctx.Web, _mockTemplate, parser, provisioningInfo);

                var parsedValue = parser.ParseString(MockToken.MockTokenKey);
                Assert.AreEqual(MockToken.MockTokenKey, parsedValue, "Disabled tokenprovider should not have provided tokens!");
            }
        }
Ejemplo n.º 2
0
        public void TokenProviderReceivesExpectedParameters()
        {
            var givenConfiguration    = "START {parameter:MOCKPARAM} END";
            var expectedConfiguration = "START MOCKPARAMVALUE END";

            using (var ctx = TestCommon.CreateClientContext())
            {
                var _mockProvider = new Provider
                {
                    Assembly      = "OfficeDevPnP.Core.Tests",
                    Type          = "OfficeDevPnP.Core.Tests.Framework.ExtensibilityCallOut.ExtensibilityMockTokenProvider",
                    Configuration = givenConfiguration,
                    Enabled       = true
                };

                var provisioningInfo = new ProvisioningTemplateApplyingInformation();
                provisioningInfo.HandlersToProcess = Handlers.All;
                provisioningInfo.ExtensibilityHandlers.Add(_mockProvider);

                var _mockTemplate = new ProvisioningTemplate();
                _mockTemplate.Parameters.Add("MOCKPARAM", "MOCKPARAMVALUE");
                _mockTemplate.Id = ExtensibilityTestConstants.PROVISIONINGTEMPLATE_ID;
                _mockTemplate.ExtensibilityHandlers.Add(_mockProvider);

                var extensibilityHandler = new ObjectExtensibilityHandlers();
                var parser = new TokenParser(ctx.Web, _mockTemplate);
                extensibilityHandler.AddExtendedTokens(ctx.Web, _mockTemplate, parser, provisioningInfo);

                Assert.AreSame(ctx, ExtensibilityMockTokenProvider.ReceivedCtx, "Wrong clientContext passed to the provider.");
                Assert.AreSame(_mockTemplate, ExtensibilityMockTokenProvider.ReceivedProvisioningTemplate, "Wrong template passed to the provider.");
                Assert.AreEqual(expectedConfiguration, ExtensibilityMockTokenProvider.ReceivedConfigurationData, "Wrong configuration data passed to the provider.");
            }
        }
Ejemplo n.º 3
0
        public void TokenProviderProvidesTokens()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                var _mockProvider = new Provider
                {
                    Assembly      = "PnP.Framework.Test",
                    Type          = "PnP.Framework.Test.Framework.ExtensibilityCallOut.ExtensibilityMockTokenProvider",
                    Configuration = ExtensibilityTestConstants.PROVIDER_MOCK_DATA,
                    Enabled       = true
                };

                var provisioningInfo = new ProvisioningTemplateApplyingInformation
                {
                    HandlersToProcess = Handlers.All
                };
                provisioningInfo.ExtensibilityHandlers.Add(_mockProvider);

                var _mockTemplate = new ProvisioningTemplate
                {
                    Id = ExtensibilityTestConstants.PROVISIONINGTEMPLATE_ID
                };
                _mockTemplate.ExtensibilityHandlers.Add(_mockProvider);

                var extensibilityHandler = new ObjectExtensibilityHandlers();
                var parser = new TokenParser(ctx.Web, _mockTemplate);
                extensibilityHandler.AddExtendedTokens(ctx.Web, _mockTemplate, parser, provisioningInfo);

                var parsedValue = parser.ParseString(MockToken.MockTokenKey);
                Assert.AreEqual(MockToken.MockTokenValue, parsedValue);
            }
        }
Ejemplo n.º 4
0
        public void TokenProviderProvidesTokens()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                var _mockProvider = new Provider
                {
                    Assembly      = "OfficeDevPnP.Core.Tests",
                    Type          = "OfficeDevPnP.Core.Tests.Framework.ExtensibilityCallOut.ExtensibilityMockTokenProvider",
                    Configuration = ExtensibilityTestConstants.PROVIDER_MOCK_DATA,
                    Enabled       = true
                };

                var _mockTemplate = new ProvisioningTemplate();
                _mockTemplate.Id = ExtensibilityTestConstants.PROVISIONINGTEMPLATE_ID;
                _mockTemplate.Providers.Add(_mockProvider);

                var extensibilityHandler = new ObjectExtensibilityHandlers();
                var parser = new TokenParser(ctx.Web, _mockTemplate);
                extensibilityHandler.AddExtendedTokens(ctx.Web, _mockTemplate, parser, null);

                var parsedValue = parser.ParseString(MockToken.MockTokenKey);
                Assert.AreEqual(MockToken.MockTokenValue, parsedValue);
            }
        }