Microsoft.Protocols.TestSuites.MS_LISTSWS.S03_OperationOnListItem.MSLISTSWS_S03_TC94_UpdateListItems_PreCalcIgnore C# (CSharp) Method

MSLISTSWS_S03_TC94_UpdateListItems_PreCalcIgnore() private method

private MSLISTSWS_S03_TC94_UpdateListItems_PreCalcIgnore ( ) : void
return void
        public void MSLISTSWS_S03_TC94_UpdateListItems_PreCalcIgnore()
        {
            // Create a list.
            string listId = TestSuiteHelper.CreateList();

            // Read value from configuration file.
            string validFieldName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site);

            // Construct one insert item.
            List<Dictionary<string, string>> items = new List<Dictionary<string, string>>(1);
            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);
            Dictionary<string, string> item1 = new Dictionary<string, string>();
            item1.Add(validFieldName, TestSuiteHelper.GenerateRandomString(5));
            items.Add(item1);
            cmds.Add(MethodCmdEnum.New);

            // Construct the UpdateListItemsUpdates instance and set the PreCalc attribute to true.
            UpdateListItemsUpdates updates = TestSuiteHelper.CreateUpdateListItems(cmds, items, OnErrorEnum.Return);
            updates.Batch.PreCalc = "TRUE";
            UpdateListItemsResponseUpdateListItemsResult resultWhenPreCalcTrue = null;
            resultWhenPreCalcTrue = this.listswsAdapter.UpdateListItems(
                                                                listId,
                                                                updates);

            // In the z:row, verify the attribute value which is specified by validFieldName is equal,
            // and for all the other attribute there is no guarantee. So all the other attributes in the z:row 
            // will be ignored except the specified one. 
            foreach (UpdateListItemsResponseUpdateListItemsResultResult result in resultWhenPreCalcTrue.Results)
            {
                foreach (XmlElement row in result.Any)
                {
                    IgnoreAttributeExcept(
                                    row,
                                    validFieldName);
                }
            }

            // Reset the PreCalc to some invalid value.
            updates.Batch.PreCalc = "NotValidBoolean";
            UpdateListItemsResponseUpdateListItemsResult resultWhenPreCalcInvalid = null;
            resultWhenPreCalcInvalid = this.listswsAdapter.UpdateListItems(
                                                                listId,
                                                                updates);

            // In the z:row, we can only make sure the attribute value which 
            // is specified by validFieldName is equal, for all the other attribute there is no 
            // guarantee. So all the other attributes in the z:row will be ignored except the 
            // specified one. 
            foreach (UpdateListItemsResponseUpdateListItemsResultResult result in resultWhenPreCalcInvalid.Results)
            {
                foreach (XmlElement row in result.Any)
                {
                    IgnoreAttributeExcept(
                                    row,
                                    validFieldName);
                }
            }

            // If ignore some field in z:row element and both result are same, capture R2294.
            bool isSame = TestSuiteHelper.DeepCompare(resultWhenPreCalcTrue, resultWhenPreCalcInvalid);
            Site.CaptureRequirementIfIsTrue(
                  isSame,
                  2294,
                  "[In UpdateListItems operation] [In UpdateListItems element] [In updates element]"
                       + "[In Batch element] [PreCalc attribute] The response of server will be same for"
                       + "different values of PreCalc.");
        }
S03_OperationOnListItem