/// <summary> /// The DeleteVersion operation is used to delete a specific version of the specified file. /// </summary> /// <param name="fileName">The site-relative path of the file name whose version is to be deleted.</param> /// <param name="fileVersion">The number of the file version to be deleted.</param> /// <returns>The response message for deleting a version of the specified file on the protocol server.</returns> public DeleteVersionResponseDeleteVersionResult DeleteVersion(string fileName, string fileVersion) { try { fileVersion = fileVersion.Replace("@", string.Empty); DeleteVersionResponseDeleteVersionResult deleteVersionResult = this.service.DeleteVersion( fileName, fileVersion); this.VerifyTransport(); this.VerifySOAPVersion(this.service.SoapVersion); this.VerifyDeleteVersion(deleteVersionResult, SchemaValidation.LastRawResponseXml.OuterXml); return(deleteVersionResult); } catch (SoapException soapException) { this.VerifySOAPFaultDetails(soapException, SchemaValidation.LastRawResponseXml.OuterXml); throw; } catch (WebException) { this.VerifyServerFaults(); throw; } }
/// <summary> /// Verify the DeleteVersion operation related requirements. /// </summary> /// <param name="deleteVersionResult">The DeleteVersionResponseDeleteVersionResult object indicates /// DeleteVersion operation response.</param> /// <param name="soapBody">The string value indicates the SOAP body in DeleteVersion operation response.</param> private void VerifyDeleteVersion(DeleteVersionResponseDeleteVersionResult deleteVersionResult, string soapBody) { bool isSchemaVerified = SchemaValidation.ValidationResult.Equals(ValidationResult.Success); #region Verify MS-VERSS_R99 // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R99"); // Verify MS-VERSS requirement: MS-VERSS_R99 Site.CaptureRequirementIfIsTrue( isSchemaVerified, 99, @"[In DeleteVersion][The schema of DeleteVersion is defined as:] <wsdl:operation name=""DeleteVersion""> <wsdl:input message=""tns:DeleteVersionSoapIn"" /> <wsdl:output message=""tns:DeleteVersionSoapOut"" /> </wsdl:operation>"); #endregion #region Verify MS-VERSS_R101 // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R101"); // Verify MS-VERSS requirement: MS-VERSS_R101 Site.CaptureRequirementIfIsNotNull( deleteVersionResult, 101, @"[In DeleteVersion] [The protocol client sends a DeleteVersionSoapIn request message,] and the protocol server responds with a DeleteVersionSoapOut response message."); #endregion #region Verify MS-VERSS_R107 // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R107"); bool isR107Verified = AdapterHelper.IsExistElementInSoapBody(soapBody, "DeleteVersionResponse"); // Verify MS-VERSS requirement: MS-VERSS_R107 Site.CaptureRequirementIfIsTrue( isR107Verified, 107, @"[In DeleteVersionSoapOut] The SOAP body contains a DeleteVersionResponse element."); #endregion #region Verify MS-VERSS_R111 // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R111"); // Verify MS-VERSS requirement: MS-VERSS_R111 Site.CaptureRequirementIfIsTrue( isSchemaVerified, 111, @"[In DeleteVersionResponse][The schema of DeleteVersionResponse element is defined as:] <s:element name=""DeleteVersionResponse""> <s:complexType> <s:sequence> <s:element minOccurs=""1"" maxOccurs=""1"" name=""DeleteVersionResult""> <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(deleteVersionResult.results, isSchemaVerified); }
/// <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."); }