Beispiel #1
0
        /// <summary>
        /// Common Test for URL Rewriting
        /// </summary>
        /// <param name="input"></param>
        /// <param name="sourceSite"></param>
        /// <param name="sourceWeb"></param>
        /// <param name="targetWeb"></param>
        /// <param name="pagesLibrary"></param>
        /// <param name="expected"></param>
        public void CommonUrlReWriteTest(string input, string sourceSite, string sourceWeb, string targetWeb, string pagesLibrary, string expected)
        {
            //Pre-requisite objects
            using (var targetClientContext = TestCommon.CreateClientContext("https://capadevtest.sharepoint.com/sites/PnPSauceModern"))
            {
                using (var sourceClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPODevSiteUrl")))
                {
                    PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
                    {
                        // If target page exists, then overwrite it
                        Overwrite = true,
                        // Don't log test runs
                        SkipTelemetry = true,

                        KeepPageCreationModificationInformation = false,
                    };

                    UrlTransformator urlTransform = new UrlTransformator(pti, sourceClientContext, targetClientContext);

                    var result = urlTransform.ReWriteUrls(input, sourceSite, sourceWeb, targetWeb, pagesLibrary);

                    Assert.AreEqual(expected, result);
                }
            }
        }
Beispiel #2
0
        public MyCustomFunctions(BaseTransformationInformation baseTransformationInformation, ClientContext pageClientContext, ClientContext sourceClientContext, ClientSidePage clientSidePage, IList <ILogObserver> logObservers) : base(pageClientContext)
        {
            if (logObservers != null)
            {
                foreach (var observer in logObservers)
                {
                    base.RegisterObserver(observer);
                }
            }

            // This is an optional property, in cross site transfer the two contexts would be different.
            this.sourceClientContext           = sourceClientContext;
            this.clientSidePage                = clientSidePage;
            this.baseTransformationInformation = baseTransformationInformation;
            this.urlTransformator              = new UrlTransformator(baseTransformationInformation, this.sourceClientContext, this.clientContext, base.RegisteredLogObservers);
            this.userTransformator             = new UserTransformator(baseTransformationInformation, this.sourceClientContext, this.clientContext, base.RegisteredLogObservers);
        }
        /// <summary>
        /// Common call to class we are testing
        /// </summary>
        /// <param name="input"></param>
        /// <param name="sourceSiteUrl"></param>
        /// <param name="sourceWebUrl"></param>
        /// <param name="targetWebUrl"></param>
        /// <param name="expected"></param>
        public void TestUrlTransform(string input, string sourceSiteUrl, string sourceWebUrl, string targetWebUrl, string expected)
        {
            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPODevSiteUrl")))
                {
                    List <ILogObserver> observers = new List <ILogObserver>
                    {
                        new UnitTestLogObserver()
                    };

                    var pagesLibrary = "pages";

                    // Context doesnt matter what is used
                    UrlTransformator urlTransform = new UrlTransformator(null, sourceClientContext, targetClientContext, observers);
                    var result = urlTransform.ReWriteUrls(input, sourceSiteUrl, sourceWebUrl, targetWebUrl, pagesLibrary);

                    Console.WriteLine(result);
                    Assert.AreEqual(expected, result);
                }
            }
        }