Пример #1
0
        /// <summary>
        /// Note: this test will only work if the files are present at the parts of the sharepoint site
        /// and the source site originates from a sub site
        /// </summary>
        /// <param name="url"></param>
        private void AssetTransferOfAsset(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                Assert.Inconclusive("You havent provided a URL");
            }

            url = url.TrimStart('/'); //Remove slash at the beginning

            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPODevSiteUrl")))
                {
                    // Needs valid client contexts as they are part of the checks.
                    AssetTransfer assetTransfer = new AssetTransfer(sourceClientContext, targetClientContext);
                    assetTransfer.RegisterObserver(new UnitTestLogObserver());

                    var siteUrl = sourceClientContext.Site.EnsureProperty(o => o.ServerRelativeUrl);
                    var target  = $"{TestCommon.AppSetting("SPOTargetSiteUrl")}/SiteAssets/";

                    var sourceImageLocation = $"{siteUrl}/{url}";

                    assetTransfer.EnsureAssetContextIfRequired(sourceClientContext, sourceImageLocation);

                    var result = assetTransfer.CopyAssetToTargetLocation(sourceImageLocation, target);

                    Assert.IsTrue(!string.IsNullOrEmpty(result));
                }
            }
        }
Пример #2
0
        public void AssetTransfer_TransferAsset_EnsureContextTest()
        {
            //Note: This is more of a system test rather than unit given its dependency on SharePoint
            // Scenario here is when the source context is a subsite and the image asset is on the Site Collection

            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPORootDevSiteUrl")))
                {
                    // Needs valid client contexts as they are part of the checks.
                    AssetTransfer assetTransfer = new AssetTransfer(sourceClientContext, targetClientContext);

                    var siteUrl = sourceClientContext.Site.EnsureProperty(o => o.ServerRelativeUrl);
                    var target  = $"{TestCommon.AppSetting("SPOTargetSiteUrl")}/SiteAssets/";

                    var sourceImageLocation = $"{siteUrl}/en/PublishingImages/extra.jpg";

                    assetTransfer.EnsureAssetContextIfRequired(sourceClientContext, sourceImageLocation);

                    var result = assetTransfer.CopyAssetToTargetLocation(sourceImageLocation, target);

                    Assert.IsTrue(!string.IsNullOrEmpty(result));
                }
            }
        }
Пример #3
0
        public void AssetTransfer_CopyAssetToTarget_SmallFileTest()
        {
            //Note: This is more of a system test rather than unit given its dependency on SharePoint

            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPODevTeamSiteUrl")))
                {
                    AssetTransfer assetTransfer = new AssetTransfer(sourceClientContext, targetClientContext);

                    var targetWebUrl = targetClientContext.Web.EnsureProperty(o => o.ServerRelativeUrl);
                    var sourceWebUrl = sourceClientContext.Web.EnsureProperty(o => o.ServerRelativeUrl);

                    // Very crude test - ensure the site is setup for this ahead of the test
                    var sourceFileServerRelativeUrl = $"{sourceWebUrl}/SiteImages/extra8_500x500.jpg";
                    var targetLocation = $"{targetWebUrl}/Shared%20Documents"; //Shared Documents for example, Site Assets may not exist on vanilla sites

                    assetTransfer.CopyAssetToTargetLocation(sourceFileServerRelativeUrl, targetLocation);
                }
            }

            Assert.Inconclusive(TestCommon.InconclusiveNoAutomatedChecksMessage);
        }
Пример #4
0
        public void AssetTransfer_CopyAssetToTarget_LargeFileTest()
        {
            //Note: This is more of a system test rather than unit given its dependency on SharePoint

            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPODevTeamSiteUrl")))
                {
                    AssetTransfer assetTransfer = new AssetTransfer(sourceClientContext, targetClientContext);

                    // Very crude test - ensure the site is setup for this ahead of the test
                    // Note this file is not included in this project assets due to its licensing. Pls find a > 3MB file to use as a test.
                    var targetWebUrl = targetClientContext.Web.EnsureProperty(o => o.ServerRelativeUrl);
                    var sourceWebUrl = sourceClientContext.Web.EnsureProperty(o => o.ServerRelativeUrl);

                    var sourceFileServerRelativeUrl = $"{sourceWebUrl}/SiteImages/bigstock-Html-Web-Code-57446159.jpg";
                    var targetLocation = $"{targetWebUrl}/Shared%20Documents"; //Shared Documents for example, Site Assets may not exist on vanilla sites

                    assetTransfer.CopyAssetToTargetLocation(sourceFileServerRelativeUrl, targetLocation);
                }
            }

            Assert.Inconclusive(TestCommon.InconclusiveNoAutomatedChecksMessage);
        }