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

MSLISTSWS_S03_TC67_UpdateListItemWithKnowledge_FieldNotExist() private method

        public void MSLISTSWS_S03_TC67_UpdateListItemWithKnowledge_FieldNotExist()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(25151, this.Site), @"Test is executed only when R25151Enabled is set to true.");

            string listName = TestSuiteHelper.GetUniqueListName();
            TestSuiteHelper.CreateList(listName);

            // Call UpdateListItem operation to add one item using non-exists field name
            string fieldName = TestSuiteHelper.GetUniqueFieldName();
            List<MethodCmdEnum> cmds = new List<MethodCmdEnum>(1);
            cmds.Add(MethodCmdEnum.New);
            List<Dictionary<string, string>> items = new List<Dictionary<string, string>>(1);
            Dictionary<string, string> item = new Dictionary<string, string>();
            item.Add(fieldName, TestSuiteHelper.GenerateRandomString(5));
            items.Add(item);
            UpdateListItemsWithKnowledgeUpdates updates = TestSuiteHelper.CreateUpdateListWithKnowledgeItems(cmds, items);
            UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult result = null;
            result = this.listswsAdapter.UpdateListItemsWithKnowledge(
                                                listName,
                                                updates,
                                                null,
                                                null);

            this.Site.Assert.AreEqual<int>(
                                1,
                                result.Results.Length,
                                "If only insert one item, then there will be one result element.");

            // Verify MS-LISTSWS requirement: MS-LISTSWS_R2356
            Site.CaptureRequirementIfAreNotEqual<string>(
                "0x00000000",
                result.Results[0].ErrorCode,
                2356,
                @"[In UpdateListItemsWithKnowledge operation] [In UpdateListItemsWithKnowledge element] [In updates element] [In Batch element] [In Method element] [In Field element]  The protocol server MUST return an error indicating why the update failed, if the field is not a special field.");

            this.Site.CaptureRequirementIfIsTrue(
                result.Results[0].ErrorCode.IndexOf("0x", StringComparison.OrdinalIgnoreCase) == 0,
                2324,
                @"[In UpdateListItemsWithKnowledgeResult][In UpdateListItemsWithKnowledgeResponse][In UpdateListItemsWithKnowledgeResult element] Otherwise, [If an operation does not complete successfully] the ErrorCode MUST be set to a hexadecimal representation of the error encountered.");

            // Verify MS-LISTSWS requirement: MS-LISTSWS_R2367
            Site.CaptureRequirementIfIsNotNull(
                AdapterHelper.GetElementValue(result.Results[0].Any, "ErrorText"),
                2367,
                @"[In UpdateListItemsWithKnowledgeResult][In UpdateListItemsWithKnowledgeResponse][In UpdateListItemsWithKnowledgeResult element] Otherwise, [If an operation does not complete successfully] the ErrorText element MUST have a description of the error.");
        }
S03_OperationOnListItem