Exemple #1
0
        /// <summary>
        /// Get the template item from TemplateDataWorkflowTemplate array by specified name.
        /// </summary>
        /// <param name="templates">A parameter represents the TemplateDataWorkflowTemplate array which the method perform on.</param>
        /// <param name="templateName">A parameter represent the name of the expected template item.</param>
        /// <returns>A return value represents the template item matched the specified name.</returns>
        private TemplateDataWorkflowTemplate GetTemplateItemByName(TemplateDataWorkflowTemplate[] templates, string templateName)
        {
            if (null == templates)
            {
                throw new ArgumentNullException("templates");
            }

            if (0 == templates.Length)
            {
                throw new ArgumentException("The templates' collection should contain at least one template item.", "templates");
            }

            if (string.IsNullOrEmpty(templateName))
            {
                throw new ArgumentNullException("templateName");
            }

            var templateItemMatchName = from templateItem in templates
                                        where templateItem.Name.Equals(WorkflowAssociationName)
                                        select templateItem;

            this.Site.Assert.AreNotEqual <int>(
                0,
                templateItemMatchName.Count(),
                "The templates' collection should contain at least one template item with name[{0}]",
                templateName);

            TemplateDataWorkflowTemplate expectedTemplateItem = templateItemMatchName.ElementAt <TemplateDataWorkflowTemplate>(0);

            return(expectedTemplateItem);
        }
        /// <summary>
        /// Get the association data from specified templateItem in response of GetTemplatesForItem operation.
        /// </summary>
        /// <param name="templateName">A parameter represents the template name which will be used to find out the template item</param>
        /// <param name="templateData">A parameter represents response of GetTemplatesForItem operation which contains the association data.</param>
        /// <returns>A return represents the association data.</returns>
        public static XmlNode GetAssociationDataFromTemplateItem(string templateName, TemplateData templateData)
        {
            TemplateDataWorkflowTemplate currentWorkflowTemplateItem = GetWorkFlowTemplateItemByName(templateName, templateData);

            if (null == currentWorkflowTemplateItem)
            {
                site.Assert.Fail(
                    "The response of getTemplatesForItem operation should contain template item with expected name[{0}]",
                    templateName);
            }

            return(currentWorkflowTemplateItem.AssociationData);
        }
        /// <summary>
        /// Get the WorkFlow Template Item By specified Name
        /// </summary>
        /// <param name="templateName">A parameter represents the template name which will be used to find out the template item</param>
        /// <param name="templateData">A parameter represents response of GetTemplatesForItem operation.</param>
        /// <returns>A return represents the template item data.</returns>
        public static TemplateDataWorkflowTemplate GetWorkFlowTemplateItemByName(string templateName, TemplateData templateData)
        {
            if (string.IsNullOrEmpty(templateName) || null == templateData)
            {
                string errMsg = string.Format(
                    "All Parameters should not be null or empty: templateName[{0}] getTemplatesForItemResult[{1}]",
                    string.IsNullOrEmpty(templateName) ? "NullOrEmpty" : "Valid",
                    null == templateData ? "Null" : "Valid");
                throw new ArgumentException(errMsg);
            }

            if (null == templateData.WorkflowTemplates)
            {
                site.Assert.Fail("Could not get the valid TemplateData from the response of GetTemplatesForItem operation.");
            }

            TemplateDataWorkflowTemplate[] templates = templateData.WorkflowTemplates;

            var expectedTemplateItems = from templateItem in templates
                                        where templateItem.Name.Equals(templateName, StringComparison.OrdinalIgnoreCase)
                                        select templateItem;

            TemplateDataWorkflowTemplate matchTemplateItem = null;
            int itemsCounter = expectedTemplateItems.Count();

            if (1 < itemsCounter)
            {
                site.Assert.Fail("The response of GetTemplatesForItem operation should contain only one matched TemplateData item.");
            }
            else if (0 == itemsCounter)
            {
                return(matchTemplateItem);
            }
            else
            {
                matchTemplateItem = expectedTemplateItems.ElementAt(0);
            }

            return(matchTemplateItem);
        }
Exemple #4
0
        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.");
        }