Microsoft.Protocols.TestSuites.MS_VERSS.S03_ErrorConditions.MSVERSS_S03_TC06_RestoreVersionNotCheckout C# (CSharp) Method

MSVERSS_S03_TC06_RestoreVersionNotCheckout() private method

private MSVERSS_S03_TC06_RestoreVersionNotCheckout ( ) : void
return void
        public void MSVERSS_S03_TC06_RestoreVersionNotCheckout()
        {
            // The variable is used to save the soap error code returned from server.
            string errorCode = string.Empty;

            // Enable the versioning of the list.
            bool isSetVersioningSuccess = 
                this.sutControlAdapterInstance.SetVersioning(this.documentLibrary, true, true);
            Site.Assert.IsTrue(
                isSetVersioningSuccess, 
                "SetVersioning operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isSetVersioningSuccess);

            // Upload the file into specific list.
            bool isAddFileSuccess =
                this.sutControlAdapterInstance.AddFile(this.documentLibrary, this.fileName, TestSuiteHelper.UploadFileName);
            Site.Assert.IsTrue(
                isAddFileSuccess, 
                "AddFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isAddFileSuccess);

            // Check out and check in file three times to create three versions of the file. 
            this.testSuiteHelper.AddFileVersions();

            // Enforce check out in the list.
            bool isSetServerEnforceCheckOutSuccess =
                this.sutControlAdapterInstance.SetEnforceCheckout(this.documentLibrary, true);
            Site.Assert.IsTrue(
                isSetServerEnforceCheckOutSuccess,
                "SetServerEnforceCheckOut operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isSetServerEnforceCheckOutSuccess);

            // Call GetVersions with the relative filename to get details about all versions of the file.
            GetVersionsResponseGetVersionsResult getVersionsResponse = 
                this.protocolAdapterInstance.GetVersions(this.fileRelativeUrl);
            this.testSuiteHelper.VerifyResultsInformation(getVersionsResponse.results, OperationName.GetVersions, true);

            // This variable is used to save the version that needs to be restored.
            string restoreFileVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            if (Common.IsRequirementEnabled(18801, this.Site) || Common.IsRequirementEnabled(205, this.Site))
            {
                try
                {
                    // Call RestoreVersion operation to restore the file which is not checked out. 
                    this.protocolAdapterInstance.RestoreVersion(this.fileRelativeUrl, restoreFileVersion);
                    Site.Assert.Fail("The RestoreVersion operation should fail since the file is not" +
                        " checked out when check out is enforced.");
                }
                catch (SoapException ex)
                {
                    GetVersionsResponseGetVersionsResult getVersionsResponseAfterRestore =
                        this.protocolAdapterInstance.GetVersions(this.fileRelativeUrl);
                    bool isResponseNotChange = AdapterHelper.AreVersionsResultEqual(
                        getVersionsResponse.results.result,
                        getVersionsResponseAfterRestore.results.result);

                    errorCode = Common.ExtractErrorCodeFromSoapFault(ex);
                    Site.Log.Add(LogEntryKind.Debug, "The errorCode is {0}.", errorCode);

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R136");

                    // Verify MS-VERSS requirement: MS-VERSS_R136 
                    // Since there is a returned error which indicates the operation is not allowed if the file
                    // is not checked out when check out is enforced, and the file versions are not changed, so R136 can be captured.
                    Site.CaptureRequirementIfIsTrue(
                        isResponseNotChange,
                        136,
                        @"[In RestoreVersion] If the file is not already at the checked out publishing level, and the protocol server enforces that only checked out files can be modified, this operation MUST NOT allow the restoration of the file.");

                    if (Common.IsRequirementEnabled(18801, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R18801");

                        // Verify MS-VERSS requirement: MS-VERSS_R18801
                        Site.CaptureRequirementIfAreEqual<string>(
                            "0x8007009e",
                            errorCode,
                            18801,
                            @"[In Appendix B: Product Behavior] Implementation returns the error code 0x8007009E to indicate that the file is not checked out, the error code is 0x8007009E. (SharePoint Foundation 2010 and above follow this behavior.)");
                    }

                    if (Common.IsRequirementEnabled(205, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R205");

                        // Verify MS-VERSS requirement: MS-VERSS_R205
                        Site.CaptureRequirementIfAreEqual<string>(
                           "0x81070975",
                           errorCode,
                           205,
                           @"[In Appendix B: Product Behavior] Implementation does return error code 0x81070975. (<9> Section 3.1.4.4.2.2:  Windows SharePoint Services 3.0 returns error code 0x81070975.)");
                    }
                }
            }
        }