コード例 #1
0
        /// <summary>
        /// The UpdateListItems operation is used to insert, update, and delete to specified list items in a list.
        /// </summary>
        /// <param name="listName">The name of the list for which list items will be updated</param>
        /// <param name="updates">Specifies the operations to perform on a list item</param>
        /// <returns>return the updated list items</returns>
        public UpdateListItemsResponseUpdateListItemsResult UpdateListItems(string listName, UpdateListItemsUpdates updates)
        {
            if (null == this.listsProxy)
            {
                throw new InvalidOperationException("The Proxy instance is NULL, need to initialize the adapter");
            }

            UpdateListItemsResponseUpdateListItemsResult result = null;

            result = this.listsProxy.UpdateListItems(listName, updates);
            this.VerifyTransportRequirement();

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Verify the message syntax of UpdateListItems operation when the response is received 
        /// successfully.
        /// </summary>
        /// <param name="updateListItemsResult">The result of the operation.</param>
        /// <param name="updates">The updates parameter of the method.</param>
        private void VerifyUpdateListItemsOperation(
            UpdateListItemsResponseUpdateListItemsResult updateListItemsResult,
            UpdateListItemsUpdates updates)
        {
            // Verify R2067
            // The response have been received successfully, then the following requirement can be captured.
            // If the response is not received and parsed successfully, the test case will fail before this requirement is captured 
            Site.CaptureRequirement(
                2067,
                @"[The schema of UpdateListItems is defined as:]"
                + @"<wsdl:operation name=""UpdateListItems"">"
                + @"    <wsdl:input message=""UpdateListItemsSoapIn"" />"
                + @"    <wsdl:output message=""UpdateListItemsSoapOut"" />"
                + @"</wsdl:operation>");

            // Verify R905
            // The response have been received successfully, then the following requirement can be captured.
            // If the response is not received and parsed successfully, the test case will fail before this requirement is captured 
            Site.CaptureRequirement(
                905,
                @"[In UpdateListItems operation] [If the protocol client sends an "
                + "UpdateListItemsSoapIn request message] the protocol server responds with an "
                + "UpdateListItemsSoapOut response message.");

            // Verify R2072
            // The response have been received successfully, then the following requirement can be captured.
            // If the response is not received and parsed successfully, the test case will fail before this requirement is captured 
            Site.CaptureRequirement(
                2072,
                @"[UpdateListItemsSoapOut]The SOAP Body contains an UpdateListItemsResponse "
                + "element");

            // Verify R2111
            // The response have been received successfully, then the following requirement can be captured.
            // If the response is not received and parsed successfully, the test case will fail before this requirement is captured 
            Site.CaptureRequirement(
                2111,
                @"[The schema of UpdateListItemsResponse is defined as:]  <s:element name=""UpdateListItemsResponse"">
                <s:complexType>
                  <s:sequence>
                    <s:element minOccurs=""0"" maxOccurs=""1"" name=""UpdateListItemsResult"">
                      <s:complexType mixed=""true"">
                        <s:sequence>
                          <s:element name=""Results"" >
                            <s:complexType>
                              <s:sequence>
                                <s:element name=""Result"" maxOccurs=""unbounded"">
                                  <s:complexType>
                                    <s:sequence>
                                      <s:element name=""ErrorCode"" type=""s:string"" />
                                              <s:any minOccurs=""0"" maxOccurs=""unbounded"" />
                                    </s:sequence>
                                  <s:attribute name=""ID"" type=""s:string"" />
                                <s:attribute name=""List"" type=""s:string""/>
                              <s:attribute name=""Version"" type=""s:string""/>
                            </s:complexType>
                          </s:element>
                        </s:sequence>
                      </s:complexType>
                    </s:element>
                  </s:sequence>
                </s:complexType>
              </s:element>
            </s:sequence>
          </s:complexType></s:element>");

            // Ensure the SOAP result is de-serialized successfully.
            Site.Assume.IsNotNull(
                updateListItemsResult,
                "The result of UpdateListItems operation must not be null.");

            // If the first returned ID attribute is the Method ID, followed by a comma, 
            // followed by the Method operation, then the following requirements can be 
            // captured.
            for (int i = 0; i < updates.Batch.Method.Length; i++)
            {
                bool isVerifyR962 = false;
                bool isVerifyR923 = false;
                string[] strID = updateListItemsResult.Results[i].ID.Split(',');
                if (strID[0] == updates.Batch.Method[i].ID.ToString() && strID[1] == updates.Batch.Method[i].Cmd.ToString())
                {
                    isVerifyR962 = true;
                    isVerifyR923 = true;
                }

                // Verify R962
                Site.CaptureRequirementIfIsTrue(
                isVerifyR962,
                962,
                @"[In UpdateListItems operation] [In UpdateListItemsResponse element] [In "
                + "UpdateListItemsResult element] The ID attribute of the Method parameters "
                + "MUST correspond to the ID attribute of the Result element and the Result ID "
                + "is the Method ID, followed by a comma, followed by the Method operation.");

                // Verify R923
                Site.CaptureRequirementIfIsTrue(
                isVerifyR923,
                923,
                @"[In UpdateListItems operation] [In UpdateListItems element] [In updates "
                + "element] [In Method element] If the Method ID attribute is unique, the protocol "
                + "server MUST use the method identification to match up the request made to the "
                + "protocol server with the protocol server response.");
                //
                if ((updateListItemsResult.Results[i].ID == null || updateListItemsResult.Results[i].ID.ToString() == "") && (updateListItemsResult.Results[i].ErrorCode != ""))
                {
                Site.CaptureRequirement(
                    2323001,
                    @"An empty ID element following the ErrorCode element is included, which is reserved for future use. ");
                }
            }

            // Verify R2115
            // The response have been received successfully, then the following requirement can be captured.
            // If the response is not received and parsed successfully, the test case will fail before this requirement is captured 
            Site.CaptureRequirement(
                2115,
                @"[UpdateListItemsResponse]The Result element MUST contain an ErrorCode element.");
        }
コード例 #3
0
        /// <summary>
        /// A method used to verify the response of UpdateListItems operation whether contain "Result" item under "Results" element. If the response does not contain any  "Result" items, this method will throw Assert exception.
        /// </summary>
        /// <param name="responseOfUpdateListItems">A parameter represents the response of UpdateListItems operation which expected to contain "Result" item under "Results" element.</param>
        /// <param name="expectedItemNumber">A parameter represents the how many items the response of UpdateListItems operation expected to contain. If does not specified the expectedItemNumber value, method will not perform the expected items' number verification.</param>
        protected void VerifyContainResultItem(UpdateListItemsResponseUpdateListItemsResult responseOfUpdateListItems, int? expectedItemNumber)
        {
            if (null == responseOfUpdateListItems)
            {
                throw new ArgumentNullException("responseOfUpdateListItems");
            }

            int expectedItemNumberValue = -1;
            if (expectedItemNumber.HasValue)
            {
                expectedItemNumberValue = expectedItemNumber.Value;
                if (expectedItemNumberValue < 0)
                {
                    string errorMessage = string.Format(@"The value should be larger than or equal to zero. actual value:[{0}]", expectedItemNumberValue);
                    throw new ArgumentException(errorMessage, "expectedItemNumber");
                }
            }

            this.Site.Assert.IsNotNull(
                    responseOfUpdateListItems.Results,
                    "The response of UpdateListItems operation should contain [Results] element.");

            this.Site.Assert.AreNotEqual<int>(
                        0,
                        responseOfUpdateListItems.Results.Length,
                        "The response of UpdateListItems operation should contain at least one [Result] item.");

            // If does not specified the expectedItemNumber value, method will not perform the verification.
            if (!expectedItemNumber.HasValue)
            {
                return;
            }

            this.Site.Assert.AreEqual<int>(
                                    expectedItemNumberValue,
                                    responseOfUpdateListItems.Results.Length,
                                    "The response of UpdateListItems operation should contain expected number of [Result] items.");
        }
コード例 #4
0
        /// <summary>
        /// A method is used to verify the result for UpdateListItem operation. If not all the update operation succeed, this method will throw Assert exception.
        /// </summary>
        /// <param name="updateResult">The response of the UpdateListItem operation.</param>
        protected void VerifyResponseOfUpdateListItem(UpdateListItemsResponseUpdateListItemsResult updateResult)
        {
            if (null == updateResult)
            {
                throw new ArgumentNullException("updateResult");
            }

            this.Site.Assert.IsNotNull(updateResult.Results, "The response of UpdateListItems operation should contain the Results element.");

            foreach (UpdateListItemsResponseUpdateListItemsResultResult res in updateResult.Results)
            {
                // If the UpdateListItem success, the ErrorCode is "0x00000000".
                if ("0x00000000".Equals(res.ErrorCode, StringComparison.OrdinalIgnoreCase))
                {
                    if (res.Any != null && res.Any.Count() > 0)
                    {
                        this.Site.Log.Add(LogEntryKind.Debug, "UpdateListItem operation successfully.");
                    }
                    else
                    {
                        this.Site.Assert.Fail("The Result element should contains at least one zrow item.");
                    }
                }
                else
                {
                    if (res.Any != null && res.Any.Count() > 0)
                    {
                        foreach (XmlElement elementItem in res.Any)
                        {
                            if (elementItem.Name.Equals("ErrorText", StringComparison.OrdinalIgnoreCase))
                            {
                                // Export the error message for the result of UpdateListItem.
                                this.Site.Log.Add(LogEntryKind.Warning, ErrorMessageTemplate, "UpdateListItem operation fail:" + elementItem.InnerText);
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// A method used to get list item id collection from the operation of UpdateListItems operation. If the [expectedUpdatedListItem] parameter specified value and the response does not contain expected list items' id record, method will throw Assert exception.
        /// </summary>
        /// <param name="updateListItemResponse">A parameter represents the response of UpdateListItems operation.</param>
        /// <param name="expectedUpdatedListItem">A parameter represents the expected number of updated list items. The method will perform a check: if the actual number of updated list items does not equal to this value, this method will throw a Assert Exception. Specified this value to null means the method does not perform the check process.</param>
        /// <returns>A return value presents all updated list items' id</returns>
        protected List<string> GetListItemIdsFromUpdateListItemsResponse(UpdateListItemsResponseUpdateListItemsResult updateListItemResponse, int? expectedUpdatedListItem)
        {
            List<string> listItemIdsTemp = new List<string>();
            if (null == updateListItemResponse)
            {
                throw new ArgumentNullException("updateListItemResponse");
            }

            if (null == updateListItemResponse.Results || 0 == updateListItemResponse.Results.Length)
            {
                this.Site.Assert.Fail("The response of UpdateListItem operation should contain at least one record of updated list item.");
            }

            foreach (UpdateListItemsResponseUpdateListItemsResultResult updateResultItem in updateListItemResponse.Results)
            {
                XmlNode[] zrowsItem = this.GetZrowItems(updateResultItem.Any);

                for (int updatedItemIndex = 0; updatedItemIndex < zrowsItem.Length; updatedItemIndex++)
                {
                    string idvalue = Common.GetZrowAttributeValue(zrowsItem, updatedItemIndex, "ows_ID");
                    listItemIdsTemp.Add(idvalue);
                }
            }

            if (expectedUpdatedListItem.HasValue)
            {
                // Each result item means a update process for a list item.
                this.Site.Assert.AreEqual(
                    expectedUpdatedListItem.Value,
                    listItemIdsTemp.Count,
                    "The actual updated list items' number should match the expected number:[{0}].",
                    expectedUpdatedListItem.Value);
            }

            return listItemIdsTemp;
        }