/// <summary> /// A method used to upload a txt file to the destination SUT. /// </summary> /// <param name="fileUrl">A parameter represents the expected URL of a file which will be uploaded into the destination SUT. The file URL must point to the destination SUT which is indicated by "SutComputerName" property in "SharePointCommonConfiguration.deployment.ptfconfig" file.</param> protected void UploadTxtFileByFileUrl(string fileUrl) { if (null == MSCOPYSSutControlAdapter) { throw new InvalidOperationException("The SUT control adapter is not initialized."); } FileUrlHelper.ValidateFileUrl(fileUrl); bool isFileUploadSuccessful = MSCOPYSSutControlAdapter.UploadTextFile(fileUrl); if (!isFileUploadSuccessful) { this.Site.Assert.Fail("Could not upload a txt file to the destination SUT. Expected file URL:[{0}]", fileUrl); } this.CollectFileToRecorder(fileUrl); }
public static void ClassCleanup() { if (null != FilesUrlRecordOfDestination && 0 != FilesUrlRecordOfDestination.Count) { StringBuilder strBuilder = new StringBuilder(); foreach (string fileUrlItem in FilesUrlRecordOfDestination) { strBuilder.Append(fileUrlItem + @";"); } string fileUrlValues = strBuilder.ToString(); bool isDeleteAllFilesSuccessful; isDeleteAllFilesSuccessful = MSCOPYSSutControlAdapter.DeleteFiles(fileUrlValues); if (!isDeleteAllFilesSuccessful) { throw new InvalidOperationException("Not all the files are deleted clearly."); } } TestClassBase.Cleanup(); }
public void MSCOPYS_S02_TC04_CopyIntoItemsLocal_DestinationCheckedOut() { // Get the value of the source file URL. string sourceFileUrl = this.GetSourceFileUrl(SourceFileUrlType.SourceFileOnDesSUT); // Get the first destination location. string desFileUrl1 = this.GetDestinationFileUrl(DestinationFileUrlType.NormalDesLibraryOnDesSUT); // Upload a txt file to the destination SUT. this.UploadTxtFileByFileUrl(desFileUrl1); string[] desUrls = new string[] { desFileUrl1 }; // Check out the file by the specified user. MSCOPYSSutControlAdapter.CheckOutFileByUser( desFileUrl1, Common.GetConfigurationPropertyValue("MSCOPYSCheckOutUserName", this.Site), Common.GetConfigurationPropertyValue("PasswordOfCheckOutUser", this.Site), Common.GetConfigurationPropertyValue("Domain", this.Site)); // Copy files in same SUT with check out source file. CopyIntoItemsLocalResponse copyIntoItemsLocalResponse = MSCopysAdapter.CopyIntoItemsLocal( sourceFileUrl, desUrls); this.Site.Assert.IsNotNull(copyIntoItemsLocalResponse.Results, "The element Results should be return if CopyIntoItemsLocal operation executes successfully"); this.Site.Assert.IsTrue(1 == copyIntoItemsLocalResponse.Results.Length, "The Results element should contain one CopyResult element."); // Collect files from specified file URLs. this.CollectFileByUrl(desUrls); // Verify MS-COPYS requirement: MS-COPYS_R155 this.Site.CaptureRequirementIfAreEqual <CopyErrorCode>( CopyErrorCode.DestinationCheckedOut, copyIntoItemsLocalResponse.Results[0].ErrorCode, 155, @"[In Abstract Data Model] In this case[files as checked out], the CopyIntoItemsLocal operations take into account the checked-out status when accessing files at the destination locations."); // Verify MS-COPYS requirement: MS-COPYS_R286 bool isVerifyR286 = !string.IsNullOrEmpty(copyIntoItemsLocalResponse.Results[0].ErrorMessage); this.Site.CaptureRequirementIfIsTrue( isVerifyR286, 286, @"[In CopyIntoItemsLocal] If the file on the protocol server is checked out and cannot be updated, the protocol server MUST report a failure of the copy operation by setting the value of the ErrorCode attribute of the corresponding CopyResult element to ""DestinationCheckedOut"", and provide a string value that specifies the error in the ErrorMessage attribute."); // Verify MS-COPYS requirement: MS-COPYS_R103 this.Site.CaptureRequirementIfAreEqual <CopyErrorCode>( CopyErrorCode.DestinationCheckedOut, copyIntoItemsLocalResponse.Results[0].ErrorCode, 103, @"[In CopyErrorCode] [For CopyIntoItemsLocal operation] DestinationCheckedOut: This value is used to indicate an error when the file on the destination location is checked out and cannot be overridden."); // Undo checkout for a file by specified user credential. MSCOPYSSutControlAdapter.UndoCheckOutFileByUser( desFileUrl1, Common.GetConfigurationPropertyValue("MSCOPYSCheckOutUserName", this.Site), Common.GetConfigurationPropertyValue("PasswordOfCheckOutUser", this.Site), Common.GetConfigurationPropertyValue("Domain", this.Site)); }