Microsoft.Protocols.TestSuites.MS_SITESS.S01_MigrateSite.MSSITESS_S01_TC01_MigratingSuccessfully C# (CSharp) Méthode

MSSITESS_S01_TC01_MigratingSuccessfully() private méthode

private MSSITESS_S01_TC01_MigratingSuccessfully ( ) : void
Résultat void
        public void MSSITESS_S01_TC01_MigratingSuccessfully()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5311, this.Site) && Common.IsRequirementEnabled(5391, this.Site), @"Test is executed only when R5311Enabled and R5391Enabled are set to true.");

            #region Variables
            string siteUrl = Common.GetConfigurationPropertyValue(Constants.SiteUrl, this.Site);
            string exportUrl = Common.GetConfigurationPropertyValue(Constants.NormalSubsiteUrl, this.Site);
            string importUrl = siteUrl + "/" + this.newSubsite;
            string dataPath = Common.GetConfigurationPropertyValue(Constants.DataPath, this.Site);
            string logPath = string.Empty;
            string exportJobName = Constants.ExportJobName + Common.FormatCurrentDateTime();
            string importJobName = Constants.ImportJobName + Common.FormatCurrentDateTime();
            string[] dataFiles = new string[] { dataPath + "/" + exportJobName + Constants.CmpExtension };
            int cabSize = 50;
            int exportWebResult = 0;
            int importWebResult = 0;
            string[] exportWebFiles = null;
            string[] expectedWebFiles = null;
            string exportWebStatusCode = string.Empty;
            string importWebStatusCode = string.Empty;

            #endregion Variables

            // Initialize the web service with an authenticated account.
            this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated);

            // Invoke the ExportWeb operation with valid parameters, 1 is expected to be returned and only one cmp file is expected to be exported.
            exportWebResult = this.sitessAdapter.ExportWeb(exportJobName, exportUrl, dataPath, true, true, true, cabSize);

            #region Capture requirements

            // If 1 is returned, requirements related with ExportWeb pending can be verified.
            this.VerifyExportWebInProgress(exportWebResult);

            #endregion Capture requirements

            string files = TestSuiteHelper.VerifyExportAndImportFile(exportJobName, 2, this.Site, this.sutAdapter);
            exportWebFiles = files == null ? null : files.TrimEnd(new char[] { ';' }).Split(';');

            // Format the expected file names in the document library. Only one cmp file (i.e. ExportWeb.cmp) is expected to be exported in the document library.
            expectedWebFiles = new string[]
            {
                exportJobName + Constants.CmpExtension,
                exportJobName + Constants.SntExtension
            };

            exportWebStatusCode = this.sutAdapter.GetStatusCode(string.Empty, string.Empty, Common.GetConfigurationPropertyValue(Constants.ValidLibraryName, this.Site), exportJobName + Constants.SntExtension);

            #region Capture requirements

            if (Common.IsRequirementEnabled(329, this.Site))
            {
                // If a status code is included in the file which is generated by ExportWeb, R329 can be captured.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R329");

                // Verify MS-SITESS requirement: MS-SITESS_R329
                Site.CaptureRequirementIfAreNotEqual<string>(
                    string.Empty,
                    exportWebStatusCode,
                    329,
                    @"[In Appendix B: Product Behavior][<3> Section 3.1.4.2:] The file [which contains the result of the export operation] includes a status code indicating the success of the operation or an error code. (Microsoft Office SharePoint Server 2007 and above follow this behavior.)");
            }

            if (Common.IsRequirementEnabled(328, this.Site))
            {
                // If a status code is included in the file which is generated by ExportWeb, it means the file 
                // that contains the result of the export operation has been successfully generated. R328 can be captured.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R328");

                // Verify MS-SITESS requirement: MS-SITESS_R328
                Site.CaptureRequirementIfAreNotEqual<string>(
                    string.Empty,
                    exportWebStatusCode,
                    328,
                    @"[In Appendix B: Product Behavior] <3> Section 3.1.4.2: Implementation does creates a file that contains the result of the export operation in the server location specified in the request message. (Microsoft Office SharePoint Server 2007 and above follow this behavior.)");
            }

            if (Common.IsRequirementEnabled(433001, this.Site))
            {
                for (int i = 0; i < expectedWebFiles.Length; i++)
                {
                    // If a status code is included in the file which is generated by ExportWeb, it means the file 
                    // that contains the result of the export operation has been successfully generated. R433001 can be captured.
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R433001");

                    // Verify MS-SITESS requirement: MS-SITESS_R433001
                    Site.CaptureRequirementIfAreNotEqual<string>(
                        string.Empty,
                        exportWebFiles[i],
                        433001,
                        @"[In Appendix B: Product Behavior] [<3> Section 3.1.4.2:] If the export operation succeeds, this file also includes the list of the content migration package files created. (Microsoft Office SharePoint Server 2007 and above follow this behavior.)");
                }
            }

            // Verify whether the exported file is Content Migration Package(.cmp) file. Since all the exported file and log file are compared, the file name of the exported file is also verified.
            bool isCmpFile = AdapterHelper.CompareStringArrays(expectedWebFiles, exportWebFiles);

            // If export web files is .cmp file, R71 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R71, the expected Content Migration Package(.cmp) file is {0}, and the exported file name list is {1}", expectedWebFiles[0], files);

            // Verify MS-SITESS requirement: MS-SITESS_R71
            Site.CaptureRequirementIfIsTrue(
                isCmpFile,
                71,
                @"[In ExportWeb] [jobName:] The server MUST append the file extension .cmp to the jobName to form the file name for the first content migration package file.");

            // If export web files is .cmp file, R60 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R60, the expected Content Migration Package(.cmp) file is {0}", expectedWebFiles[0]);

            // Verify MS-SITESS requirement: MS-SITESS_R60
            Site.CaptureRequirementIfIsTrue(
                isCmpFile,
                60,
                @"[In ExportWeb] Upon the successful completion of the export operation, the Content Migration Package file(s) MUST be created in the server location specified in the request message.");

            #endregion Capture requirements

            logPath = dataPath;

            // Invoke the ImportWeb operation with valid parameters, 1 is expected to be returned.
            importWebResult = this.sitessAdapter.ImportWeb(importJobName, importUrl, dataFiles, logPath, true, true);

            #region Capture requirements

            // If 1 is returned, requirements related with ImportWeb pending can be verified.
            this.VerifyImportWebInProgress(importWebResult);
            this.isWebImportedSuccessfully = true;

            DateTime beforeLoop = DateTime.Now;
            TimeSpan waitTime = new TimeSpan();
            int repeatTime = 0;
            int totalRepeatTime = Convert.ToInt32(Common.GetConfigurationPropertyValue(Constants.ImportWebRepeatTime, this.Site));
            do
            {
                // It is assumed that the server will generate the status code of ImportWeb operation after the preconfigured time period.
                int sleepTime = Convert.ToInt32(Common.GetConfigurationPropertyValue(Constants.ImportWebWaitTime, this.Site));
                Thread.Sleep(1000 * sleepTime);

                // Get the status code in the log file.
                importWebStatusCode = this.sutAdapter.GetStatusCode(string.Empty, string.Empty, Common.GetConfigurationPropertyValue(Constants.ValidLibraryName, this.Site), importJobName + Constants.SntExtension);

                // If the returned status code is not null, the operation is considered as succeed.
                if (!string.IsNullOrEmpty(importWebStatusCode))
                {
                    break;
                }

                // If the server could not generate the status code after the time period ImportWebWaitTime for some unknown reasons, for example, limit of server resources, try to repeat this sequence again.
                repeatTime++;
            }
            while (repeatTime < totalRepeatTime);
            waitTime = DateTime.Now - beforeLoop;

            // If the server still does not generate the status code after repeating, the operation is considered as failed.
            if (string.IsNullOrEmpty(importWebStatusCode))
            {
                Site.Assert.Fail("The result of the import operation was not received after {0} seconds", waitTime);
            }

            if (Common.IsRequirementEnabled(340, this.Site))
            {
                // If a status code is included in the file which is generated by ImportWeb, R340 can be captured.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R340");

                // Verify MS-SITESS requirement: MS-SITESS_R340
                // Since the returned status code is not empty, this requirement can be captured directly.
                Site.CaptureRequirement(
                    340,
                    @"[In Appendix B: Product Behavior][<14> Section 3.1.4.8:] The file [which contains the result of the import operation] includes a status code indicating the success of the operation or an error code. (Microsoft Office SharePoint Server 2007 and above follow this behavior.)");
            }

            if (Common.IsRequirementEnabled(339, this.Site))
            {
                // If a status code is included in the file which is generated by ImportWeb, it means the file 
                // that contains the result of the export operation has been successfully generated. R339 can be captured.
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R339");

                // Verify MS-SITESS requirement: MS-SITESS_R339
                // Since the returned status code is not empty, this requirement can be captured directly.
                Site.CaptureRequirement(
                    339,
                    @"[In Appendix B: Product Behavior] <14> Section 3.1.4.8: Windows SharePoint Services creates a file that contains the result of the import operation in the server location specified in the request message. (Microsoft Office SharePoint Server 2007 and above follow this behavior.)");
            }
            #endregion Capture requirements

            #region Capture requirements

            // Verify that Microsoft Windows SharePoint Services 3.0 and above support operation ExportWeb.
            this.VerifyOperationExportWeb();

            // Verify that Microsoft Windows SharePoint Services 3.0 and above support operation ImportWeb.
            this.VerifyOperationImportWeb();

            #endregion Capture requirements
        }