/// <summary>
        /// This operation is used to get details about all versions of the specified file that the user can access.
        /// </summary>
        /// <param name="fileName">The site-relative path of a file on the protocol server.</param>
        /// <returns>The response message for getting all versions of the specified file that the user can access.</returns>
        public GetVersionsResponseGetVersionsResult GetVersions(string fileName)
        {
            try
            {
                GetVersionsResponseGetVersionsResult getVersionsResult = this.service.GetVersions(fileName);

                this.VerifyTransport();
                this.VerifySOAPVersion(this.service.SoapVersion);
                this.VerifyGetVersions(getVersionsResult, SchemaValidation.LastRawResponseXml.OuterXml);

                return(getVersionsResult);
            }
            catch (SoapException soapException)
            {
                this.VerifySOAPFaultDetails(soapException, SchemaValidation.LastRawResponseXml.OuterXml);
                throw;
            }
            catch (WebException)
            {
                this.VerifyServerFaults();
                throw;
            }
        }
예제 #2
0
        /// <summary>
        /// Verify the GetVersions operation related requirements.
        /// </summary>
        /// <param name="getVersionResult">The GetVersionsResponseGetVersionsResult object
        /// indicates GetVersions operation response.</param>
        /// <param name="soapBody">The string value indicates the SOAP body in GetVersions operation response.</param>
        private void VerifyGetVersions(GetVersionsResponseGetVersionsResult getVersionResult, string soapBody)
        {
            bool isSchemaVerified = SchemaValidation.ValidationResult.Equals(ValidationResult.Success);

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

            // Verify MS-VERSS requirement: MS-VERSS_R119
            Site.CaptureRequirementIfIsTrue(
                isSchemaVerified,
                119,
                @"[In GetVersions][The schema of GetVersions is defined as:]
<wsdl:operation name=""GetVersions"">
    <wsdl:input message=""tns:GetVersionsSoapIn"" />
    <wsdl:output message=""tns:GetVersionsSoapOut"" />
</wsdl:operation>");
            #endregion

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

            // Verify MS-VERSS requirement: MS-VERSS_R121
            Site.CaptureRequirementIfIsNotNull(
                getVersionResult,
                121,
                @"[In GetVersions] [The protocol client sends a GetVersionsSoapIn request message,] and the protocol server responds with a GetVersionsSoapOut response message.");
            #endregion

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

            bool isR127Verified = AdapterHelper.IsExistElementInSoapBody(soapBody, "GetVersionsResponse");

            // Verify MS-VERSS requirement: MS-VERSS_R127
            Site.CaptureRequirementIfIsTrue(
                isR127Verified,
                127,
                @"[In GetVersionsSoapOut] The SOAP body contains a GetVersionsResponse element.");
            #endregion

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

            // Verify MS-VERSS requirement: MS-VERSS_R130
            Site.CaptureRequirementIfIsTrue(
                isSchemaVerified,
                130,
                @"[In GetVersionsResponse][The schema of GetVersionsResponse element is defined as:]  
<s:element name=""GetVersionsResponse"">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs=""1"" maxOccurs=""1"" name=""GetVersionsResult"">
        <s:complexType>
          <s:sequence>
            <s:element name=""results"" minOccurs=""1"" maxOccurs=""1"" type=""tns:Results"" />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:sequence>
  </s:complexType>
</s:element>");
            #endregion

            this.VerifyResultsComplexType(getVersionResult.results, isSchemaVerified);
        }
        /// <summary>
        /// A common method used to verify that the client uses the RestoreVersion operation to successfully restore
        /// the file specified by a URL to a specific version when check out is enforced.
        /// </summary>
        /// <param name="url">The URL of a file.</param>
        private void RestoreVersionVerification(string url)
        {
            // Enable the versioning of the list.
            bool setVersioning = this.sutControlAdapterInstance.SetVersioning(this.documentLibrary, true, true);

            Site.Assert.IsTrue(
                setVersioning,
                "SetVersioning operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                setVersioning);

            // Upload the file into specific list.
            bool isAddFileSuccessful = this.sutControlAdapterInstance.AddFile(this.documentLibrary, this.fileName, TestSuiteHelper.UploadFileName);

            Site.Assert.IsTrue(
                isAddFileSuccessful,
                "AddFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isAddFileSuccessful);

            // Check out and check in file one time to create a new version of the file.
            this.testSuiteHelper.AddOneFileVersion(this.fileName);

            // Enforce the file to be checked out.
            bool setServerEnforceCheckOut = this.sutControlAdapterInstance.SetEnforceCheckout(this.documentLibrary, true);

            Site.Assert.IsTrue(
                setServerEnforceCheckOut,
                "SetServerEnforceCheckOut operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                setServerEnforceCheckOut);

            // Call GetVersions operation using relative fileName.
            GetVersionsResponseGetVersionsResult getVersionsResponse = this.protocolAdapterInstance.GetVersions(
                url);

            // Verify the GetVersions results.
            this.testSuiteHelper.VerifyResultsInformation(getVersionsResponse.results, OperationName.GetVersions, true);

            // Check out the specified file.
            bool isCheckOutFile = this.listsSutControlAdaterInstance.CheckoutFile(this.fileAbsoluteUrl);

            Site.Assert.IsTrue(
                isCheckOutFile,
                "CheckOutFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckOutFile);

            // Get the current version of the file.
            string currentVersionBeforeRestore = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Get the previous version which is specific to be restored.
            string restoreVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Call RestoreVersion operation using relative fileName and restore a specified file to a specific version.
            RestoreVersionResponseRestoreVersionResult restoreVersionReponse = this.protocolAdapterInstance.RestoreVersion(
                url, restoreVersion);

            // Check in the specified file.
            bool isCheckInFile = this.listsSutControlAdaterInstance.CheckInFile(
                this.fileAbsoluteUrl,
                TestSuiteHelper.FileComments,
                ((int)VersionType.MinorCheckIn).ToString());

            Site.Assert.IsTrue(
                isCheckInFile,
                "CheckInFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckInFile);

            // Verify the RestoreVersion results.
            this.testSuiteHelper.VerifyResultsInformation(restoreVersionReponse.results, OperationName.RestoreVersion, true);

            // Get the current version in RestoreVersion response.
            string currentVersionAfterRestore = AdapterHelper.GetCurrentVersion(restoreVersionReponse.results.result);

            // Verify whether the current version was increased by RestoreVersion.
            bool isCurrentVersionIncreased = AdapterHelper.IsCurrentVersionIncreased(
                currentVersionBeforeRestore,
                currentVersionAfterRestore);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-VERSS_R182, the current version before RestoreVersion is {0}, and after RestoreVersion is {1}",
                currentVersionBeforeRestore,
                currentVersionAfterRestore);

            // Verify MS-VERSS requirement: MS-VERSS_R182
            Site.CaptureRequirementIfIsTrue(
                isCurrentVersionIncreased,
                182,
                @"[In RestoreVersion] After the restoration, the current version number of the file MUST still be increased, as with any other change.");
        }
        public void MSVERSS_S02_TC03_RestoreVersionWithoutEnforceCheckout()
        {
            // Enable the versioning of the list.
            bool setVersioning = this.sutControlAdapterInstance.SetVersioning(this.documentLibrary, true, true);

            Site.Assert.IsTrue(
                setVersioning,
                "SetVersioning operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                setVersioning);

            // Protocol server does not enforce that only checked out files can be modified.
            bool isSetServerEnforceCheckOut = this.sutControlAdapterInstance.SetEnforceCheckout(this.documentLibrary, false);

            Site.Assert.IsTrue(
                isSetServerEnforceCheckOut,
                "SetServerEnforceCheckOut operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isSetServerEnforceCheckOut);

            // Upload the first file into specific list.
            bool isAddFileSuccessful = this.sutControlAdapterInstance.AddFile(this.documentLibrary, this.fileName, TestSuiteHelper.UploadFileName);

            Site.Assert.IsTrue(
                isAddFileSuccessful,
                "AddFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isAddFileSuccessful);

            // Check out and check in first file to add the file versions.
            this.testSuiteHelper.AddOneFileVersion(this.fileName);

            // Call GetVersions operation using absolute fileName.
            GetVersionsResponseGetVersionsResult getVersionsResponse = this.protocolAdapterInstance.GetVersions(this.fileAbsoluteUrl.AbsoluteUri);

            // Verify the GetVersions results.
            this.testSuiteHelper.VerifyResultsInformation(getVersionsResponse.results, OperationName.GetVersions, true);

            // Get the current version.
            string currentVersionBeforeRestore = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Get the previous version which is specific to be restored.
            string restoreVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Call RestoreVersion operation using absolute fileName and restore a specified file to a specific version.
            RestoreVersionResponseRestoreVersionResult restoreVersionNotCheckOutResponse =
                this.protocolAdapterInstance.RestoreVersion(this.fileAbsoluteUrl.AbsoluteUri, restoreVersion);

            // Verify the RestoreVersion results.
            this.testSuiteHelper.VerifyResultsInformation(restoreVersionNotCheckOutResponse.results, OperationName.RestoreVersion, true);

            // Get the current version in RestoreVersion response.
            string currentVersionAfterNotCheckOutRestore = AdapterHelper.GetCurrentVersion(
                restoreVersionNotCheckOutResponse.results.result);

            // Verify whether the current version after RestoreVersion is increased when the file is not checked out.
            bool isCurrentVersionIncreased = AdapterHelper.IsCurrentVersionIncreased(
                currentVersionBeforeRestore,
                currentVersionAfterNotCheckOutRestore);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-VERSS_R185, if the file is not checked out, the current version before RestoreVersion is {0}," +
                " and after RestoreVersion is {1}",
                currentVersionBeforeRestore,
                currentVersionAfterNotCheckOutRestore);

            // Verify MS-VERSS requirement: MS-VERSS_R185
            Site.CaptureRequirementIfIsTrue(
                isCurrentVersionIncreased,
                185,
                @"[In RestoreVersion] If the file is not checked out before the restoration, the current version number of the file MUST still be increased, as with any other change.");

            // Check out the file.
            bool isCheckOutFile = this.listsSutControlAdaterInstance.CheckoutFile(this.fileAbsoluteUrl);

            Site.Assert.IsTrue(
                isCheckOutFile,
                "CheckOutFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckOutFile);

            // Call GetVersions operation using absolute fileName.
            getVersionsResponse = this.protocolAdapterInstance.GetVersions(this.fileAbsoluteUrl.AbsoluteUri);

            // Get current version before RestoreVersion operation in GetVersions response.
            currentVersionBeforeRestore = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Get the previous version which is specific to be restored.
            restoreVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Call RestoreVersion operation using absolute fileName and restore a specified file to a specific version.
            RestoreVersionResponseRestoreVersionResult restoreVersionIsCheckOutResponse =
                this.protocolAdapterInstance.RestoreVersion(this.fileAbsoluteUrl.AbsoluteUri, restoreVersion);

            // Get the current version in RestoreVersion response.
            string currentVersionAfterIsCheckOutRestore = AdapterHelper.GetCurrentVersion(
                restoreVersionIsCheckOutResponse.results.result);

            // Add the debug information
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-VERSS_R186, if the file is checked out, the current version before RestoreVersion is {0}," +
                " and after RestoreVersion is {1}",
                currentVersionBeforeRestore,
                currentVersionAfterIsCheckOutRestore);

            // Verify MS-VERSS requirement: MS-VERSS_R186
            Site.CaptureRequirementIfAreEqual <string>(
                currentVersionBeforeRestore,
                currentVersionAfterIsCheckOutRestore,
                186,
                @"[In RestoreVersion] If the file is checked out, the current version number of the file after restoration MUST remain the same as before restoration.");

            // Check in file.
            bool isCheckInFile = this.listsSutControlAdaterInstance.CheckInFile(
                this.fileAbsoluteUrl,
                TestSuiteHelper.FileComments,
                ((int)VersionType.MinorCheckIn).ToString());

            Site.Assert.IsTrue(
                isCheckInFile,
                "CheckInFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isCheckInFile);
        }
        /// <summary>
        /// A common method used to verify that the client can get expected DeleteAllVersionsSoapOut and
        /// GetVersionsSoapOut messages by calling DeleteAllVersions and GetVersions operations with the URL of a file.
        /// </summary>
        /// <param name="url">The URL of a file.</param>
        private void DeleteAllVersionsVerification(string url)
        {
            // Enable the versioning of the list.
            bool setVersioning = this.sutControlAdapterInstance.SetVersioning(this.documentLibrary, true, true);

            Site.Assert.IsTrue(
                setVersioning,
                "SetVersioning operation returns {0}, TRUE means the operation was executed successfully, " +
                "FALSE means the operation failed",
                setVersioning);

            // Upload the file into specific list.
            bool isAddFileSuccessful = this.sutControlAdapterInstance.AddFile(this.documentLibrary, this.fileName, TestSuiteHelper.UploadFileName);

            Site.Assert.IsTrue(
                isAddFileSuccessful,
                "AddFile operation returns {0}, TRUE means the operation was executed successfully, " +
                " FALSE means the operation failed",
                isAddFileSuccessful);

            // Check out and check in file one time to create a new version of the file.
            this.testSuiteHelper.AddOneFileVersion(this.fileName);

            // Call SUT Control Adapter method SetFilePublish to publish the current version of the file.
            bool isFilePublished = this.sutControlAdapterInstance.SetFilePublish(this.documentLibrary, this.fileName, true);

            Site.Assert.IsTrue(
                isFilePublished,
                "SetFilePublish operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isFilePublished);

            // Call GetVersions with the relative filename to get details about all versions of the file.
            GetVersionsResponseGetVersionsResult getVersionsResponse = this.protocolAdapterInstance.GetVersions(url);

            // Verify the GetVersions response results.
            this.testSuiteHelper.VerifyResultsInformation(getVersionsResponse.results, OperationName.GetVersions, true);

            // Get previous version before DeleteAllVersions operation by using the results element in the response of GetVersions.
            string previousVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Get the published version information by using the results element in the response of GetVersions.
            string publishedVersion = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Check out and check in file one time to create a new version of the file.
            this.testSuiteHelper.AddOneFileVersion(this.fileName);

            // Call GetVersions with the relative filename to get details about all versions of the file.
            getVersionsResponse = this.protocolAdapterInstance.GetVersions(url);

            // Get the current version information by using the results element in the response of GetVersions.
            string currentVersion = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Enable the Recycle Bin.
            bool isRecycleBinEnable = this.sutControlAdapterInstance.SetRecycleBinEnable(true);

            Site.Assert.IsTrue(
                isRecycleBinEnable,
                "SetRecycleBinEnable operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isRecycleBinEnable);

            // Call DeleteAllVersions operation with the relative filename to delete all the previous versions except
            // the published version and the current version.
            DeleteAllVersionsResponseDeleteAllVersionsResult deleteAllVersionsResponse =
                this.protocolAdapterInstance.DeleteAllVersions(url);

            // Verify DeleteAllVersions response results.
            this.testSuiteHelper.VerifyResultsInformation(deleteAllVersionsResponse.results, OperationName.DeleteAllVersions, true);

            // Verify whether the published version and the current version exist in the results element in the response
            // of DeleteAllVersions.
            bool isCurrentVersionExist =
                AdapterHelper.IsVersionExist(deleteAllVersionsResponse.results.result, currentVersion);
            bool isPublishedVersionExist = AdapterHelper.IsVersionExist(
                deleteAllVersionsResponse.results.result,
                publishedVersion);

            Site.Assert.IsTrue(
                isCurrentVersionExist,
                "The DeleteAllVersions operation should not delete the current version {0}",
                currentVersion);

            Site.Assert.IsTrue(
                isPublishedVersionExist,
                "The DeleteAllVersions operation should not delete the published version {0}",
                publishedVersion);

            // Verify whether the previous version exists in the results element in the response of DeleteAllVersions.
            bool isPreviousVersionExist = AdapterHelper.IsVersionExist(deleteAllVersionsResponse.results.result, previousVersion);

            Site.Assert.IsFalse(
                isPreviousVersionExist,
                "The DeleteAllVersions operation should delete the previous version {0}",
                previousVersion);

            // Since all the previous versions of the specified file do not exist, except for the published version and the current version, capture requirement MS-VERSS_R79.
            Site.CaptureRequirement(
                79,
                @"[In DeleteAllVersions operation] The DeleteAllVersions operation deletes all the previous versions of the specified file, except for the published version and the current version. ");

            bool isDeleteFileVersionExistInRecycleBin = false;
            bool isDeleted = false;

            foreach (VersionData versionData in getVersionsResponse.results.result)
            {
                isDeleted = !AdapterHelper.IsVersionExist(deleteAllVersionsResponse.results.result, versionData.version);
                if (isDeleted)
                {
                    // Verify whether the deleted versions exist in the Recycle Bin.
                    isDeleteFileVersionExistInRecycleBin = this.sutControlAdapterInstance.IsFileExistInRecycleBin(
                        this.fileName,
                        versionData.version);

                    if (!isDeleteFileVersionExistInRecycleBin)
                    {
                        break;
                    }
                }
            }

            // Verify MS-VERSS requirement: MS-VERSS_R169
            Site.CaptureRequirementIfIsTrue(
                isDeleteFileVersionExistInRecycleBin,
                169,
                @"[In DeleteAllVersions operation] If the Recycle Bin is enabled, the versions are placed in the Recycle Bin, instead.");
        }
        /// <summary>
        /// A common method used to verify that the client can get expected DeleteVersionSoapOut and
        /// GetVersionsSoapOut messages by calling DeleteVersion and GetVersions operations with the URL of a file.
        /// </summary>
        /// <param name="url">The URL of a file.</param>
        private void DeleteVersionVerification(string url)
        {
            // Enable the versioning of the list.
            bool setVersioning = this.sutControlAdapterInstance.SetVersioning(this.documentLibrary, true, true);

            Site.Assert.IsTrue(
                setVersioning,
                "SetVersioning operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                setVersioning);

            // Upload the file into specific list.
            bool isAddFileSuccessful = this.sutControlAdapterInstance.AddFile(this.documentLibrary, this.fileName, TestSuiteHelper.UploadFileName);

            Site.Assert.IsTrue(
                isAddFileSuccessful,
                "AddFile operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isAddFileSuccessful);

            // Check out and check in file one time to create a new version of the file.
            this.testSuiteHelper.AddOneFileVersion(this.fileName);

            // Call GetVersions with the relative filename to get details about all versions of the file.
            GetVersionsResponseGetVersionsResult getVersionsResponse =
                this.protocolAdapterInstance.GetVersions(url);

            // Verify the GetVersions response results.
            this.testSuiteHelper.VerifyResultsInformation(getVersionsResponse.results, OperationName.GetVersions, true);

            // Get the current version information by using the results element in the response of GetVersions.
            string currentVersion = AdapterHelper.GetCurrentVersion(getVersionsResponse.results.result);

            // Enable the Recycle Bin.
            bool isRecycleBinEnable = this.sutControlAdapterInstance.SetRecycleBinEnable(true);

            Site.Assert.IsTrue(
                isRecycleBinEnable,
                "SetRecycleBinEnable operation returns {0}, TRUE means the operation was executed successfully," +
                " FALSE means the operation failed",
                isRecycleBinEnable);

            // Get the version that needs to be deleted.
            string deleteFileVersion = AdapterHelper.GetPreviousVersion(getVersionsResponse.results.result);

            // Call DeleteVersion to delete a specific version of the file by using the relative filename.
            DeleteVersionResponseDeleteVersionResult deleteVersionResponse =
                this.protocolAdapterInstance.DeleteVersion(url, deleteFileVersion);

            // Verify DeleteVersion response results.
            this.testSuiteHelper.VerifyResultsInformation(deleteVersionResponse.results, OperationName.DeleteVersion, true);

            // Check whether the current version exists in the DeleteVersion response.
            bool isCurrentVersionExist =
                AdapterHelper.IsVersionExist(deleteVersionResponse.results.result, currentVersion);

            Site.Assert.IsTrue(
                isCurrentVersionExist,
                "The DeleteVersion operation should not delete the current version {0}",
                currentVersion);

            // Check whether the deleted version exists in the Recycle Bin.
            bool isDeleteFileVersionExistInRecycleBin =
                this.sutControlAdapterInstance.IsFileExistInRecycleBin(this.fileName, deleteFileVersion);

            // Verify MS-VERSS requirement: MS-VERSS_R173
            Site.CaptureRequirementIfIsTrue(
                isDeleteFileVersionExistInRecycleBin,
                173,
                @"[In DeleteVersion operation] If the Recycle Bin is enabled, the version is placed in the Recycle Bin, instead.");
        }
        /// <summary>
        /// Verify the version data information from server response results.
        /// </summary>
        /// <param name="versionData">The version data from server response results.</param>
        /// <param name="operationName">The operation name for the server response results.</param>
        private void VerifyVersionData(VersionData[] versionData, OperationName operationName)
        {
            bool areVersionsResultEqual = false;

            string fileVersionsFromSUT = string.Empty;

            // The file versions get from GetVersions response
            VersionData[] fileVersionsFromGetVersions = null;

            // If the VersionData are got from GetVersions operation, use SUT method GetFileVersions to
            // verify the VersionData. Else use protocol method GetVersions to verify the VersionData.
            if (operationName == OperationName.GetVersions)
            {
                fileVersionsFromSUT = this.sutControlAdapterInstance.GetFileVersions(this.documentLibrary, this.fileName);
                this.site.Assert.AreNotEqual <string>(
                    string.Empty,
                    fileVersionsFromSUT,
                    "GetFileVersions operation returns {0}, the not empty value means the operation executed" +
                    " successfully and the empty value means the operation failed",
                    fileVersionsFromSUT);

                // Verify that the result element returned from server using
                // Protocol Adapter equals the result element returned from server using SUT Control Adapter.
                areVersionsResultEqual = AdapterHelper.AreVersionsResultEqual(fileVersionsFromSUT, versionData);
            }
            else
            {
                // Get the relative filename of the file.
                string docRelativeUrl = this.documentLibrary + "/" + this.fileName;

                // Get the versions information from server.
                GetVersionsResponseGetVersionsResult getVersionsResponse =
                    this.protocolAdapterInstance.GetVersions(docRelativeUrl);
                fileVersionsFromGetVersions = getVersionsResponse.results.result;

                // Verify that the result element returned from server equals
                // the result element returned from GetVersions response.
                areVersionsResultEqual = AdapterHelper.AreVersionsResultEqual(fileVersionsFromGetVersions, versionData);
            }

            // Verify MS-VERSS requirement: MS-VERSS_R48
            this.site.CaptureRequirementIfIsTrue(
                areVersionsResultEqual,
                48,
                @"[In Results] result: A separate result element MUST exist for each version of the file that the user can access.");

            string responseVersionData = TransformVersionDataToString(versionData);

            switch (operationName)
            {
            case OperationName.GetVersions:

                // Add the debug information
                this.site.Log.Add(
                    LogEntryKind.Debug,
                    "The actual response of GetVersions is {0} and the expected response of GetVersions is {1}",
                    responseVersionData,
                    fileVersionsFromSUT);

                // Verify MS-VERSS requirement: MS-VERSS_R131
                this.site.CaptureRequirementIfIsTrue(
                    areVersionsResultEqual,
                    131,
                    @"[In GetVersionsResponse] GetVersionsResult: An XML node that conforms to the structure specified in section 2.2.4.1 and that contains the details about all the versions of the specified file that the user can access.");
                break;

            case OperationName.DeleteVersion:
                // Add the debug information
                this.site.Log.Add(
                    LogEntryKind.Debug,
                    "The actual response of DeleteVersion is {0} and the expected response of DeleteVersion is {1}",
                    responseVersionData,
                    TransformVersionDataToString(fileVersionsFromGetVersions));

                // Verify MS-VERSS requirement: MS-VERSS_R112
                this.site.CaptureRequirementIfIsTrue(
                    areVersionsResultEqual,
                    112,
                    @"[In DeleteVersionResponse] DeleteVersionResult: An XML node that conforms to the structure specified in section 2.2.4.1 and that contains the details about all the versions of the specified file that the user can access.");
                break;

            case OperationName.RestoreVersion:
                // Add the debug information
                this.site.Log.Add(
                    LogEntryKind.Debug,
                    "The actual response of RestoreVersion is {0} and the expected response of RestoreVersion is {1}",
                    responseVersionData,
                    TransformVersionDataToString(fileVersionsFromGetVersions));

                // Verify MS-VERSS requirement: MS-VERSS_R152
                this.site.CaptureRequirementIfIsTrue(
                    areVersionsResultEqual,
                    152,
                    @"[In RestoreVersionResponse] RestoreVersionResult: MUST return an XML node that conforms to the structure specified in section 2.2.4.1, which contains the details about all the versions of the specified file that the user can access.");
                break;

            case OperationName.DeleteAllVersions:
                // Add the debug information
                this.site.Log.Add(
                    LogEntryKind.Debug,
                    "The actual response of DeleteAllVersions is {0} and the expected response of DeleteAllVersions is {1}",
                    responseVersionData,
                    TransformVersionDataToString(fileVersionsFromGetVersions));

                // Verify MS-VERSS requirement: MS-VERSS_R92
                this.site.CaptureRequirementIfIsTrue(
                    areVersionsResultEqual,
                    92,
                    @"[In DeleteAllVersionsResponse] DeleteAllVersionsResult: An XML node that conforms to the structure specified in section 2.2.4.1 and that contains the  details about all the versions of the specified file that the user can access.");
                break;
            }

            foreach (VersionData data in versionData)
            {
                string specifiedVersionFileInformation = string.Empty;
                if (this.fileVersionAttributes.ContainsKey(data.version.Replace("@", string.Empty)) == false)
                {
                    // Get data version information from server.
                    specifiedVersionFileInformation = this.sutControlAdapterInstance.GetFileVersionAttributes(
                        this.documentLibrary,
                        this.fileName,
                        data.version.Replace("@", string.Empty));

                    this.fileVersionAttributes.Add(data.version.Replace("@", string.Empty), specifiedVersionFileInformation);
                }
                else
                {
                    specifiedVersionFileInformation = this.fileVersionAttributes[data.version.Replace("@", string.Empty)];
                }

                this.site.Assert.AreNotEqual <string>(
                    string.Empty,
                    specifiedVersionFileInformation,
                    "GetSpecifiedVersionFileInformation operation returns {0}, the non-empty value means the" +
                    " operation was executed successfully and the empty value means the operation failed",
                    specifiedVersionFileInformation);

                string[] attributes = specifiedVersionFileInformation.Split(new string[] { "^" }, StringSplitOptions.None);

                string expectedCreatedByName = attributes[0];
                expectedCreatedByName = expectedCreatedByName.Substring(expectedCreatedByName.IndexOf("\\", System.StringComparison.CurrentCulture) + 1);
                ulong expectedSize = ulong.Parse(attributes[1]);

                // According to Open Specification section 2.2.4.3, the createdByName attribute is an optional attribute.
                if (!string.IsNullOrEmpty(data.createdByName))
                {
                    // Verify MS-VERSS requirement: MS-VERSS_R165
                    this.site.CaptureRequirementIfAreEqual <string>(
                        expectedCreatedByName.ToLower(System.Globalization.CultureInfo.CurrentCulture),
                        data.createdByName.Substring(data.createdByName.IndexOf("\\", System.StringComparison.CurrentCulture) + 1).ToLower(System.Globalization.CultureInfo.CurrentCulture),
                        165,
                        @"[In VersionData] createdByName: The display name of the creator of the version of the file.");
                }

                // Verify MS-VERSS requirement: MS-VERSS_R64
                this.site.CaptureRequirementIfAreEqual <ulong>(
                    expectedSize,
                    data.size,
                    64,
                    @"[In VersionData] size: The size, in bytes, of the version of the file.");
            }
        }