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

MSLISTSWS_S03_TC68_UpdateListItemWithKnowledge_InvalidListVersionWithSchemaLock() private method

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

            // Create a list.
            string listID = TestSuiteHelper.CreateList();

            // Call UpdateListItems with lockSchema equals true and version is not the current version
            Dictionary<string, string> listItem = new Dictionary<string, string>();
            listItem.Add(
                Common.GetConfigurationPropertyValue("ListFieldText", this.Site),
                Common.GetConfigurationPropertyValue("ListFieldText", this.Site));
            UpdateListItemsWithKnowledgeUpdates updates = TestSuiteHelper.CreateUpdateListWithKnowledgeItems(
                                                                 new List<MethodCmdEnum> { MethodCmdEnum.New },
                                                                 new List<Dictionary<string, string>> { listItem });

            // Call GetListItemChangesSinceToken with null change token to get current list version
            GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult sinceTokenResult = null;
            sinceTokenResult = this.listswsAdapter.GetListItemChangesSinceToken(
                                             listID,
                                             null,
                                             null,
                                             null,
                                             null,
                                             null,
                                             null,
                                             null);

            // Find the list version number.
            uint currentVersion = (uint)sinceTokenResult.listitems.Changes.List.Version;

            // Set LockSchema is TRUE
            updates.Batch.LockSchema = "TRUE";
            updates.Batch.ListVersionSpecified = true;

            // Plus the current version with 1, then the ListVersion is not valid.
            updates.Batch.ListVersion = currentVersion + 1;
            UpdateListItemsWithKnowledgeResponseUpdateListItemsWithKnowledgeResult updateItemsResult = null;
            updateItemsResult = this.listswsAdapter.UpdateListItemsWithKnowledge(
                                                    listID,
                                                    updates,
                                                    null,
                                                    null);

            // If set LockSchema is TRUE and ListVersion is specified with an error number, the SUT will return a an error code.
            Site.Assert.AreEqual<int>(
                                1,
                                updateItemsResult.Results.Length,
                                "When only insert one item, the UpdateListItems return only one result");

            // Verify MS-LISTSWS requirement: MS-LISTSWS_R2348
            Site.CaptureRequirementIfAreEqual<string>(
                "0x80070666",
                updateItemsResult.Results[0].ErrorCode,
                2348,
                @"[In UpdateListItemsWithKnowledge operation] [In UpdateListItemsWithKnowledge element] [In updates element] [In Batch element] [LockSchema attribute]  If TRUE and ListVersion is specified with a number, the protocol server MUST return a SOAP fault with error code 0x80070666 if the schema version passed in by the protocol client does not match the list schema version on the protocol server.");
        }
S03_OperationOnListItem