/// <summary> /// A method is used to add a file with unique file name into the specified document library list, and record the file URL into the AddedFilesRecorder. /// </summary> /// <param name="isMultipleResourcesPerCase">A parameter represents bool value indicating this method is used for scenario "multiple resources per case". The default value is false.</param> /// <returns>A return value represents the absolute URL of the added file.</returns> protected string AddFileToSUT(bool isMultipleResourcesPerCase = false) { string fileName = this.GetUniqueFileName(isMultipleResourcesPerCase); string addedFileUrl = SutController.AddFileToSUT(TargetDocLibraryListName, fileName); if (string.IsNullOrEmpty(addedFileUrl)) { this.Site.Assert.Fail( "Could not upload the file[{0}] to the Document library[{1}].", fileName, TargetDocLibraryListName); } string errorOfValidateFileUrl; if (!TryVerifyFileUrl(addedFileUrl, out errorOfValidateFileUrl)) { this.Site.Assert.Fail( "The Sut controller adapter does not return a valid file URL for uploaded the file[{0}] to the Document library[{1}].\r\nReturned URL:[{2}]\r\n validate error:[{3}]", fileName, TargetDocLibraryListName, addedFileUrl, errorOfValidateFileUrl); } AddedFilesRecorder.Add(addedFileUrl); return(addedFileUrl); }
public EmController(SutController sutController) { if (!sutController.Equals(null)) { _sutController = sutController; } else { throw new NullReferenceException("SutController shouldn't be null"); } }
/// <summary> /// upload a file to the specified document library and record the file URL in order to cleanup the file in test suite clean up process. /// </summary> /// <param name="documentLibraryTitle">A parameter represents the title of a document library where the file upload</param> /// <returns>A return value represents the URL of the uploaded file.</returns> protected string UploadFileToSut(string documentLibraryTitle) { if (string.IsNullOrEmpty(documentLibraryTitle)) { throw new ArgumentException("Should specify valid value to indicate the title of target document library", "documentLibraryTitle"); } string uploadFileUrl = SutController.UploadFileToDocumentLibrary(documentLibraryTitle); if (string.IsNullOrEmpty(uploadFileUrl)) { this.Site.Assert.Fail("Upload file to [{0}] list fail.", documentLibraryTitle); } UploadedFilesUrlRecorder.Add(uploadFileUrl); return(uploadFileUrl); }
public InstrumentedSutStarter(SutController sutController) { _sutController = sutController; }
public void MSWWSP_S02_TC01_GetTemplatesForItem_TemplateData() { // Upload a file. string docItemUrl = this.UploadFileToSut(DocLibraryName); // If there are any existing task for new uploaded file, this method will throw an exception. this.VerifyTaskDataOfNewUploadFile(docItemUrl); // Call method GetTemplatesForItem to get a set of workflow associations for an existing document. GetTemplatesForItemResponseGetTemplatesForItemResult getTemplatesResult = ProtocolAdapter.GetTemplatesForItem(docItemUrl); if (getTemplatesResult == null) { this.Site.Assert.Fail("GetTemplatesForItem operation is failed."); } this.Site.Assume.IsNotNull(getTemplatesResult.TemplateData.WorkflowTemplates, "Could not get the WorkflowTemplates."); this.Site.Assume.IsTrue(getTemplatesResult.TemplateData.WorkflowTemplates.Length >= 1, "The length of the WorkflowTemplates is 0"); // If the GetTemplatesForItem operation is succeed, SUT return response then R150 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R150 Site.CaptureRequirement( 150, @"[In GetTemplatesForItem] The protocol client sends a GetTemplatesForItemSoapIn request message, and the protocol server responds with a GetTemplatesForItemSoapOut response message."); // If the GetTemplatesForItem operation is succeed, SUT return TemplateDatas element in response, then R31, R147, R153, R162 and R408 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R31 Site.CaptureRequirement( 31, @"[In Elements] TemplateData specifies a set of workflow associations."); // Verify MS-WWSP requirement: MS-WWSP_R147 Site.CaptureRequirement( 147, @"[In GetTemplatesForItem] This operation obtains a set of workflow associations for a new or existing document."); // Verify MS-WWSP requirement: MS-WWSP_R153 Site.CaptureRequirement( 153, @"[In Messages] GetTemplatesForItemSoapOut specifies the response to a request for a set of workflow associations for a new or existing document."); // Verify MS-WWSP requirement: MS-WWSP_R162 Site.CaptureRequirement( 162, @"[In Elements] GetTemplatesForItemResponse contains the response to a request for a set of workflow associations for a new or existing document."); // Verify MS-WWSP requirement: MS-WWSP_R408 Site.CaptureRequirement( 408, @"[In Message Processing Events and Sequencing Rules] GetTemplatesForItem obtains a set of workflow associations that can be started on a new or existing document in a specified list."); if (getTemplatesResult.TemplateData.Web.Title != null) { string currentWebTitle = SutController.GetCurrentWebTitle(); this.Site.Assume.IsNotNull(currentWebTitle, "Could not get the current web title."); // If the value of the Web.Title is equal to the specify value, then R384 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R384 Site.CaptureRequirementIfAreEqual <string>( currentWebTitle, getTemplatesResult.TemplateData.Web.Title, 384, @"[In TemplateData] Web.Title: The title of the site for this set of workflow associations."); } if (getTemplatesResult.TemplateData.Web.Url != null) { string currentWebUrl = SutController.GetCurrentWebUrl().ToString(); this.Site.Assume.IsNotNull(currentWebUrl, "The current web URL is " + currentWebUrl); // If the value of the Web.URL is equal to the specify value, then R385 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R385 Site.CaptureRequirementIfAreEqual <string>( currentWebUrl, getTemplatesResult.TemplateData.Web.Url, 385, @"[In TemplateData] Web.Url: A site URL for this set of workflow associations."); } if (getTemplatesResult.TemplateData.List.Title != null) { // If the value of the List.Title is equal to the specify value, then R386 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R386 string titleUrlValueInResponse = getTemplatesResult.TemplateData.List.Title.ToLower(); string currentDocLibraryNameValue = DocLibraryName.ToLower(); Site.CaptureRequirementIfAreEqual <string>( currentDocLibraryNameValue, titleUrlValueInResponse, 386, @"[In TemplateData] List.Title: The title of the list for this set of workflow associations."); } if (getTemplatesResult.TemplateData.List.Url != null) { string listUrl = SutController.GetListUrlByName(DocLibraryName); this.Site.Assume.IsNotNull(listUrl, "The value of the List Url is" + listUrl); // If the value of the List.URL is equal to the specify value, then R387 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R387 listUrl = listUrl.ToLower(); string urlValueInresponse = getTemplatesResult.TemplateData.List.Url.ToLower(); Site.CaptureRequirementIfAreEqual <string>( listUrl, urlValueInresponse, 387, @"[In TemplateData] List.Url: A list URL for this set of workflow associations."); } TemplateDataWorkflowTemplate templateItem = this.GetTemplateItemByName(getTemplatesResult.TemplateData.WorkflowTemplates, WorkflowAssociationName); // If the value of the TemplateId is equal to the specify value, then R389 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R389 this.Site.Assert.IsNotNull( templateItem.WorkflowTemplateIdSet.TemplateId, "Could not get the template id for workflow association[{0}]", TestSuiteBase.WorkflowAssociationName); this.Site.CaptureRequirementIfAreEqual( new Guid(WorkflowAssociationId), templateItem.WorkflowTemplateIdSet.TemplateId, 389, @"[In TemplateData] WorkflowTemplates.WorkflowTemplate.WorkflowTemplateIdSet.TemplateId: A GUID identifying this workflow association."); // Get workflowassociation name string baseId = SutController.GetBaseIdOfWorkFlowAssociation(DocLibraryName, WorkflowAssociationName); this.Site.Assume.IsNotNull(baseId, "The value of the BaseId id " + baseId); // If the value of the BaseId is equal to the specify value, then R390 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R390 this.Site.Assert.IsNotNull( templateItem.WorkflowTemplateIdSet.BaseId, "Could not get the BaseId for workflow association[{0}]", TestSuiteBase.WorkflowAssociationName); this.Site.CaptureRequirementIfAreEqual( new Guid(baseId), templateItem.WorkflowTemplateIdSet.BaseId, 390, @"[In TemplateData] WorkflowTemplates.WorkflowTemplate.WorkflowTemplateIdSet.BaseId: A GUID identifying the workflow template upon which this workflow association is based."); // If the value of the Name is equal to the specify value, then R391 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R391 this.Site.Assert.IsFalse( string.IsNullOrEmpty(templateItem.Name), "Could not get the Name for workflow association[{0}]", TestSuiteBase.WorkflowAssociationName); string templateNameInResponse = templateItem.Name.ToLower(); string expectedName = WorkflowAssociationName.ToLower(); this.Site.CaptureRequirementIfAreEqual( expectedName, templateNameInResponse, 391, @"[In TemplateData] WorkflowTemplates.WorkflowTemplate.Name: The name of this workflow association."); // If the value of the Description is not null, then R392 should be covered. // Verify MS-WWSP requirement: MS-WWSP_R392 this.Site.CaptureRequirementIfIsNotNull( getTemplatesResult.TemplateData.WorkflowTemplates[0].Description, 392, @"[In TemplateData] WorkflowTemplates.WorkflowTemplate.Description: The description of this workflow association."); }
/// <summary> /// A method used to delete collected files. If a collected file URL is not a valid file URL, this method will ignore it. If not all the valid file URLs are processed successfully, this method will raise an InvalidOperationException. /// </summary> /// <param name="collectedFiles">A parameter represents the collected file URLs.</param> private static void DeleteCollectedFiles(List <string> collectedFiles) { if (null == collectedFiles || 0 == collectedFiles.Count) { BaseTestSite.Log.Add(LogEntryKind.Debug, "There are no added files, skip the delete process."); return; } StringBuilder invalidUrlRecorder = new StringBuilder(); StringBuilder validUrlRecorder = new StringBuilder(); StringBuilder logsForValidUrlRecorder = new StringBuilder(); foreach (string fileUrlItem in collectedFiles) { if (string.IsNullOrEmpty(fileUrlItem)) { continue; } string errorMsg; if (!TryVerifyFileUrl(fileUrlItem, out errorMsg)) { invalidUrlRecorder.AppendLine(string.Format(@"Invalid file URL:[{0}], Error:[{1}]", fileUrlItem, errorMsg)); continue; } // Construct the SUT controller input parameter. validUrlRecorder.Append(fileUrlItem + ","); // Log the files the test suite plan to delete. string fileName = TestSuiteHelper.GetFileNameFromFullUrl(fileUrlItem); logsForValidUrlRecorder.AppendLine(string.Format(@"File name:[{0}] File URL:[{1}]", fileName, fileUrlItem)); } if (invalidUrlRecorder.Length != 0) { BaseTestSite.Log.Add( LogEntryKind.Debug, "There are some invalid URLs for collected files, test suite will skip these file URLs:\r\n{0}", invalidUrlRecorder.ToString()); } BaseTestSite.Log.Add( LogEntryKind.Debug, "Test suite prepare to delete these collected files:\r\n{0}", logsForValidUrlRecorder.ToString()); // Call SUT controller method to delete files. string uploadedfilesUrls = validUrlRecorder.ToString(0, validUrlRecorder.Length - 1); bool areFilesDeletedSuccessful = false; try { areFilesDeletedSuccessful = SutController.DeleteUploadedFilesOnSUT(TargetDocLibraryListName, uploadedfilesUrls); } finally { AddedFilesRecorder.Clear(); } if (!areFilesDeletedSuccessful) { throw new InvalidOperationException("Not all the collected files are deleted successfully."); } }
public void TestSuiteBaseCleanUp() { bool isCleanUpUploadedFilesSucceed = false; bool isCleanUpStartedTasksSucceed = false; string uploadedfilesUrls = string.Empty; if (null != UploadedFilesUrlRecorder && UploadedFilesUrlRecorder.Count > 0) { StringBuilder strBuilder = new StringBuilder(); foreach (string urlsOfUploadFileItem in UploadedFilesUrlRecorder) { strBuilder.Append(urlsOfUploadFileItem + ","); } // Remove last "," symbol uploadedfilesUrls = strBuilder.ToString(0, strBuilder.Length - 1); isCleanUpUploadedFilesSucceed = SutController.CleanUpUploadedFiles(DocLibraryName, uploadedfilesUrls); UploadedFilesUrlRecorder.Clear(); } else { isCleanUpUploadedFilesSucceed = true; } string taskids = string.Empty; if (null != StartedTaskIdsRecorder && StartedTaskIdsRecorder.Count > 0) { StringBuilder strBuilder = new StringBuilder(); foreach (string taskIditem in StartedTaskIdsRecorder) { strBuilder.Append(taskIditem + ","); } // Remove last "," symbol taskids = strBuilder.ToString(0, strBuilder.Length - 1); isCleanUpStartedTasksSucceed = SutController.CleanUpStartedTasks(TaskListName, taskids); StartedTaskIdsRecorder.Clear(); } else { isCleanUpStartedTasksSucceed = true; } string cleanUpProcessLogs = string.Empty; if (!isCleanUpStartedTasksSucceed) { string taskListName = Common.GetConfigurationPropertyValue("CurrentTaskListName", this.Site); cleanUpProcessLogs = string.Format( "There are some failures when cleaning up below tasks in task list[{0}].\r\nTasks ids:\r\n{1}\r\n", taskListName, taskids); } if (!isCleanUpUploadedFilesSucceed) { string documentListName = Common.GetConfigurationPropertyValue("CurrentDocLibraryListName", this.Site); cleanUpProcessLogs = string.Format( "{0}\r\nThere are some failures when cleaning up below files in Document Library[{1}].\r\nFiles urls:\r\n{2}", cleanUpProcessLogs, documentListName, uploadedfilesUrls); } if (!string.IsNullOrEmpty(cleanUpProcessLogs)) { this.Site.Assert.Fail( "Clean up errors:\r\n{0}", cleanUpProcessLogs); } }
public void TestSuiteBaseInitialization() { Common.CheckCommonProperties(this.Site, true); // Check if MS-WWSP service is supported in current SUT. if (!Common.GetConfigurationPropertyValue <bool>("MS-WWSP_Supported", this.Site)) { SutVersion currentSutVersion = Common.GetConfigurationPropertyValue <SutVersion>("SutVersion", this.Site); this.Site.Assert.Inconclusive("This test suite does not supported under current SUT, because MS-WWSP_Supported value set to false in MS-WWSP_{0}_SHOULDMAY.deployment.ptfconfig file.", currentSutVersion); } // Initialize the variables if (string.IsNullOrEmpty(CurrentProtocolPerformAccountName)) { CurrentProtocolPerformAccountName = Common.GetConfigurationPropertyValue("MSWWSPTestAccount", TestSuiteBase.BaseTestSite); BaseTestSite.Assert.IsFalse( string.IsNullOrEmpty(CurrentProtocolPerformAccountName), @"The [MSWWSPTestAccount] property in [MS-WWSP_TestSuite.deployment.ptfconfig] file should have value."); } if (string.IsNullOrEmpty(DocLibraryName)) { DocLibraryName = Common.GetConfigurationPropertyValue("CurrentDocLibraryListName", TestSuiteBase.BaseTestSite); this.Site.Assert.IsFalse( string.IsNullOrEmpty(DocLibraryName), "The [CurrentDocLibraryListName] property in [MS-WWSP_TestSuite.deployment.ptfconfig] file should have value."); } if (string.IsNullOrEmpty(TaskListName)) { TaskListName = Common.GetConfigurationPropertyValue("CurrentTaskListName", TestSuiteBase.BaseTestSite); this.Site.Assert.IsFalse( string.IsNullOrEmpty(TaskListName), "The [CurrentTaskListName] property in [MS-WWSP_TestSuite.deployment.ptfconfig] file should have value."); } if (string.IsNullOrEmpty(WorkflowAssociationName)) { WorkflowAssociationName = Common.GetConfigurationPropertyValue("WorkflowAssociationName", TestSuiteBase.BaseTestSite); this.Site.Assert.IsFalse( string.IsNullOrEmpty(WorkflowAssociationName), "The [WorkflowAssociationName] property in [MS-WWSP_TestSuite.deployment.ptfconfig] file should have value."); } if (string.IsNullOrEmpty(DocListId)) { DocListId = SutController.GetListIdByName(DocLibraryName); this.Site.Assert.IsFalse( string.IsNullOrEmpty(DocListId), @"Should get the valid list id of the Document Library type list[""{0}""]", DocLibraryName); } if (string.IsNullOrEmpty(TaskListId)) { TaskListId = SutController.GetListIdByName(TaskListName); this.Site.Assert.IsFalse( string.IsNullOrEmpty(TaskListId), @"Should get the valid list id of the Task type list[""{0}""]", TaskListName); } if (string.IsNullOrEmpty(WorkflowAssociationId)) { WorkflowAssociationId = SutController.GetWorkflowAssociationIdByName(DocLibraryName, WorkflowAssociationName); this.Site.Assert.IsFalse( string.IsNullOrEmpty(WorkflowAssociationId), @"Should get the valid id of workflow Association[{0}] in the Document Library type list[""{1}""]", WorkflowAssociationName, DocLibraryName); } }