/// <summary>
        /// The UpdateListItemsWithKnowledge operation is used to operation is used to insert, update, and delete 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">A parameter represents the operations to perform on a list item</param>
        /// <param name="syncScope">A parameter is reserved and MUST be ignored</param>
        /// <param name="knowledge">Specifies a value to search for</param>
        /// <returns>Return items with knowledge specified</returns>
        public UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult UpdateListItemsWithKnowledge(
            string listName,
            UpdateListItemsWithKnowledgeUpdates updates, 
            string syncScope, 
            System.Xml.XmlNode knowledge)
        {
            this.Site.Assert.IsNotNull(this.listsProxy, "The Proxy instance should not be NULL. If assert failed, the adapter need to be initialized");

            UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult result = null;
            try
            {
                result = this.listsProxy.UpdateListItemsWithKnowledge(listName, updates, syncScope, knowledge);

                // Verify the requirements of the UpdateListItems operation.
                this.VerifyUpdateListItemsWithKnowledgeOperation(result, updates);

                // Verify the requirements of the transport.
                this.VerifyTransportRequirements();
            }
            catch (XmlSchemaValidationException exp)
            {
                // Log the errors and warnings
                this.LogSchemaValidationErrors();

                this.Site.Assert.Fail(exp.Message);
            }
            catch (SoapException)
            {
                this.VerifySoapExceptionFault();
                throw;
            }

            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Verify the message syntax of UpdateListItemsWithKnowledge operation when the 
        /// response is received successfully.
        /// </summary>
        /// <param name="updateListItemsWithKnowledgeResult">The result of the operation.</param>
        /// <param name="updates">The updates parameter of the method.</param>
        private void VerifyUpdateListItemsWithKnowledgeOperation(
            UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult updateListItemsWithKnowledgeResult,
            UpdateListItemsWithKnowledgeUpdates updates)
        {
            if (updateListItemsWithKnowledgeResult != null)
            {
                // Verify R1148
                // 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(
                    1148,
                    @"[The schema of UpdateListItemsWithKnowledge is defined as:]"
                    + @"<wsdl:operation name=""UpdateListItemsWithKnowledge"">"
                    + @"    <wsdl:input message=""UpdateListItemsWithKnowledgeSoapIn"" />"
                    + @"    <wsdl:output message=""UpdateListItemsWithKnowledgeSoapOut"" />"
                    + @"</wsdl:operation>");

                // Verify R1150
                // 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(
                    1150,
                    @"[In UpdateListItemsWithKnowledge]the protocol server responds with an "
                    + "UpdateListItemsWithKnowledgeSoapOut response message,");

                // Verify R1163
                // 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(
                    1163,
                    @"[In UpdateListItemsWithKnowledgeSoapOut]The SOAP Body contains an "
                    + "UpdateListItemsWithKnowledgeResponse element.");

                // Verify R1175
                // 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(
                    1175,
                    @"[The schema of UpdateListItemsWithKnowledgeresponse is defined as: ] <s:element name=""UpdateListItemsWithKnowledgeResponse"">
                  <s:complexType>
                    <s:sequence>
                      <s:element minOccurs=""0"" maxOccurs=""1"" name=""UpdateListItemsWithKnowledgeResult"">
                        <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>");

                // 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 isVerifyR2317 = false;
                    bool isVerifyR2350 = false;
                    string[] strID = updateListItemsWithKnowledgeResult.Results[i].ID.Split(',');
                    if (strID[0] == updates.Batch.Method[i].ID.ToString() && strID[1] == updates.Batch.Method[i].Cmd.ToString())
                    {
                        isVerifyR2317 = true;
                        isVerifyR2350 = true;
                    }

                    // Verify R2317
                    Site.CaptureRequirementIfIsTrue(
                        isVerifyR2317,
                        2317,
                        @"[In UpdateListItemsWithKnowledgeResult][In UpdateListItemsWithKnowledgeResponse]"
                        + "[In UpdateListItemsWithKnowledgeResult 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 R2317
                    Site.CaptureRequirementIfIsTrue(
                    isVerifyR2350,
                    2350,
                    @"[In UpdateListItemsWithKnowledge operation] [In "
                    + "UpdateListItemsWithKnowledge 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.");
                }

                // Verify R2322
                // If the response is not received and parsed successfully, the test case will fail before this requirement is captured 
                Site.CaptureRequirement(
                    2322,
                    @"[In UpdateListItemsWithKnowledgeResult][In UpdateListItemsWithKnowledgeResponse]"
                    + "[In UpdateListItemsWithKnowledgeResult element]The Result element MUST contain "
                    + "an ErrorCode element.");
            }
        }
        /// <summary>
        /// A method used to construct UpdateListItemsWithKnowledgeUpdates instance using the specified parameters.
        /// </summary>
        /// <param name="methods">A list of MethodCmdEnum to specify the operations.</param>
        /// <param name="fieldNameValuePairs">A list of items values.</param>
        /// <param name="errorhandleType">Specify the OnError of the Batch element's value.</param>
        /// <returns>Returns the UpdateListItemsUpdates instance.</returns>
        public static UpdateListItemsWithKnowledgeUpdates CreateUpdateListWithKnowledgeItems(
                        List<MethodCmdEnum> methods,
                        List<Dictionary<string, string>> fieldNameValuePairs,
                        OnErrorEnum errorhandleType)
        {
            testSite.Assert.IsNotNull(
                        methods,
                        "The parameter methods in CreateUpdateListWithKnowledgeItems cannot be null");
            testSite.Assert.IsNotNull(
                        fieldNameValuePairs,
                        "The parameter methods in CreateUpdateListWithKnowledgeItems cannot be null");

            testSite.Assert.AreEqual<int>(
                            methods.Count,
                            fieldNameValuePairs.Count,
                            "The element number in the methods and fieldNameValuePairs parameter List are same");

            UpdateListItemsWithKnowledgeUpdates updates = new UpdateListItemsWithKnowledgeUpdates();
            updates.Batch = new UpdateListItemsWithKnowledgeUpdatesBatch();

            updates.Batch.Method = new UpdateListItemsWithKnowledgeUpdatesBatchMethod[methods.Count];
            for (int i = 0; i < methods.Count; i++)
            {
                updates.Batch.OnError = errorhandleType;
                updates.Batch.OnErrorSpecified = true;
                updates.Batch.Method[i] = new UpdateListItemsWithKnowledgeUpdatesBatchMethod();
                updates.Batch.Method[i].Cmd = methods[i];

                int fieldCount = fieldNameValuePairs[i].Keys.Count;
                updates.Batch.Method[i].Field = new UpdateListItemsWithKnowledgeUpdatesBatchMethodField[fieldCount];
                int j = 0;
                foreach (KeyValuePair<string, string> keyPair in fieldNameValuePairs[i])
                {
                    updates.Batch.Method[i].Field[j] = new UpdateListItemsWithKnowledgeUpdatesBatchMethodField();
                    updates.Batch.Method[i].Field[j].Name = keyPair.Key;
                    updates.Batch.Method[i].Field[j].Value = keyPair.Value;
                    j++;
                }
            }

            return updates;
        }
Exemplo n.º 4
0
 /// <remarks/>
 public void UpdateListItemsWithKnowledgeAsync(string listName, UpdateListItemsWithKnowledgeUpdates updates, string syncScope, System.Xml.XmlNode knowledge, object userState)
 {
     if ((this.UpdateListItemsWithKnowledgeOperationCompleted == null))
     {
         this.UpdateListItemsWithKnowledgeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateListItemsWithKnowledgeOperationCompleted);
     }
     this.InvokeAsync("UpdateListItemsWithKnowledge", new object[] {
             listName,
             updates,
             syncScope,
             knowledge}, this.UpdateListItemsWithKnowledgeOperationCompleted, userState);
 }
Exemplo n.º 5
0
 /// <remarks/>
 public void UpdateListItemsWithKnowledgeAsync(string listName, UpdateListItemsWithKnowledgeUpdates updates, string syncScope, System.Xml.XmlNode knowledge)
 {
     this.UpdateListItemsWithKnowledgeAsync(listName, updates, syncScope, knowledge, null);
 }
Exemplo n.º 6
0
 /// <remarks/>
 public System.IAsyncResult BeginUpdateListItemsWithKnowledge(string listName, UpdateListItemsWithKnowledgeUpdates updates, string syncScope, System.Xml.XmlNode knowledge, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("UpdateListItemsWithKnowledge", new object[] {
             listName,
             updates,
             syncScope,
             knowledge}, callback, asyncState);
 }
Exemplo n.º 7
0
 public UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult UpdateListItemsWithKnowledge(string listName, UpdateListItemsWithKnowledgeUpdates updates, string syncScope, System.Xml.XmlNode knowledge)
 {
     object[] results = this.Invoke("UpdateListItemsWithKnowledge", new object[] {
             listName,
             updates,
             syncScope,
             knowledge});
     return ((UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult)(results[0]));
 }
        public void MSLISTSWS_S03_TC22_GetListItemChangesWithKnowledge_MetaInfo()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(24881, this.Site), @"Test is executed only when R24881Enabled is set to true.");

            // Create list.
            string listGuid = TestSuiteHelper.CreateList();

            #region Add a list item and add property on the metaInfo field

            // Add a property on the metaInfo field
            string propertyValue = Guid.NewGuid().ToString("N");

            // Add a required property "vti_contentchangeunit" by calling updatelistItemswithKnowledge
            UpdateListItemsWithKnowledgeUpdates updates = new UpdateListItemsWithKnowledgeUpdates();
            updates.Batch = new UpdateListItemsWithKnowledgeUpdatesBatch();
            updates.Batch.Method = new UpdateListItemsWithKnowledgeUpdatesBatchMethod[1];
            updates.Batch.Method[0] = new UpdateListItemsWithKnowledgeUpdatesBatchMethod();
            updates.Batch.Method[0].ID = 0;
            updates.Batch.Method[0].Cmd = MethodCmdEnum.New;
            updates.Batch.Method[0].Field = new UpdateListItemsWithKnowledgeUpdatesBatchMethodField[1];
            updates.Batch.Method[0].Field[0] = new UpdateListItemsWithKnowledgeUpdatesBatchMethodField();
            updates.Batch.Method[0].Field[0].Name = "MetaInfo";
            updates.Batch.Method[0].Field[0].Property = "vti_contentchangeunit";
            updates.Batch.Method[0].Field[0].Value = propertyValue;

            UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult updateListItemsResult = null;
            updateListItemsResult = this.listswsAdapter.UpdateListItemsWithKnowledge(
                                                                listGuid,
                                                                updates,
                                                                null,
                                                                null);

            if (null == updateListItemsResult || null == updateListItemsResult.Results || 0 == updateListItemsResult.Results.Length)
            {
                this.Site.Assert.Fail("Could not update the [vti_contentchangeunit] property for the MetaInfo field");
            }

            #endregion

            // Get the ViewFields whose Properties is true and reference field is MetaInfo.
            // "MetaInfo" is required Field in [MS-LISTSWS]
            string metaInfoFieldName = "MetaInfo";
            CamlViewFields viewFields = TestSuiteHelper.CreateViewFields(true, new List<string> { metaInfoFieldName });
            GetListItemChangesWithKnowledgeResponseGetListItemChangesWithKnowledgeResult getListItemResult = null;
            getListItemResult = this.listswsAdapter.GetListItemChangesWithKnowledge(
                                                                    listGuid,
                                                                    null,
                                                                    null,
                                                                    viewFields,
                                                                    null,
                                                                    null,
                                                                    null,
                                                                    null,
                                                                    null);

            // Verify MS-LISTSWS requirement: MS-LISTSWS_R743
            if (getListItemResult == null || getListItemResult.listitems == null
                || getListItemResult.listitems.data == null || getListItemResult.listitems.data.Any == null)
            {
                this.Site.Assert.Fail("Get list item response error.");
            }

            if (getListItemResult.listitems.data.Any.Length == 0)
            {
                this.Site.Assert.Fail("Get list item data error");
            }

            // A return value represents the schema definition which is read from specified xsd file.
            XmlNode[] anyItems = getListItemResult.listitems.data.Any;

            // "ows_MetaInfo_" is required prefix in [MS-LISTSWS]
            string expectedPrefix = "ows_MetaInfo_";
            DataTable zrowData = AdapterHelper.ExtractData(anyItems);

            // Pick up the items which begin with "ows_MetaInfo_"
            var matchColumn = from DataColumn columnItem in zrowData.Columns
                              where 0 == columnItem.ColumnName.IndexOf(expectedPrefix, StringComparison.OrdinalIgnoreCase)
                              select columnItem;

            // Find out whether there is an item that contains the added property name in the column.
            // vti_contentchangeunit is required property in [MS-LISTSWS]
            string expectedAddedPropertyName = "vti_contentchangeunit";
            bool isContaincontentchangeunit = matchColumn.Any(founder => (0 < founder.ColumnName.IndexOf(expectedAddedPropertyName, StringComparison.OrdinalIgnoreCase)));

            // If contains OWS_Metatinfo prefix
            // Verify MS-LISTSWS requirement: MS-LISTSWS_R2339
            Site.CaptureRequirementIfIsTrue(
                isContaincontentchangeunit,
                2339,
                @"[In GetListItemChangesWithKnowledge] [In viewFields element] If the Properties attribute of the ViewFields structure is set to TRUE and the MetaInfo field is referenced in FieldRef element, then properties related to the list MUST be returned with the prefix ""ows_MetaInfo_"".");

            // If contains vti_contentchangeunit MetoInfo property 
            // Verify MS-LISTSWS requirement: MS-LISTSWS_R1144
            Site.CaptureRequirementIfIsTrue(
                isContaincontentchangeunit,
                1144,
                @"[In GetListItemChangesWithKnowledgeResponse]If the protocol client requests the MetaInfo field for the list items, the protocol server MUST return the vti_contentchangeunit Metainfo property if the property was set in the item or document and the list item or document has not been updated since the time the property was set by a client.");
        }