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

MSLISTSWS_S03_TC25_GetListItemChangesWithKnowledge_SpecifiedKnowledge() private method

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

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

            // Insert 1 items
            TestSuiteHelper.AddListItems(listId, 1);

            // Get the syncKnowledge.
            GetListItemChangesWithKnowledgeResponseGetListItemChangesWithKnowledgeResult result = null;
            result = this.listswsAdapter.GetListItemChangesWithKnowledge(
                                            listId,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null);
            syncKnowledge knowledge = result.listitems.Changes.MadeWithKnowledge.syncKnowledge;
            bool isMoreChangeIncludedWithoutKnowledge = string.Compare("True", result.listitems.Changes.MoreChanges, StringComparison.OrdinalIgnoreCase) == 0;

            // Insert 20 items again
            int totalNumber = 20;
            TestSuiteHelper.AddListItems(listId, totalNumber);

            // Call GetListItemChangesWithKnowledge to get all the 20 items which are make after the knowledge is retrieved.
            GetListItemChangesWithKnowledgeKnowledge syncKnowledge = new GetListItemChangesWithKnowledgeKnowledge();
            syncKnowledge.syncKnowledge = knowledge;
            result = this.listswsAdapter.GetListItemChangesWithKnowledge(
                                            listId,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            syncKnowledge,
                                            null);

            // If the RowLimit is not specified, the server will response all changes made to list items after the knowledge data structure.
            DataTable data = AdapterHelper.ExtractData(result.listitems.data.Any);
            this.Site.Assert.AreEqual<int>(
                            totalNumber,
                            data.Rows.Count,
                            "The response will include changes made to list items after the knowledge data structure was retrieved if there are no RowLimit specified.");

            // Insert another 20 items again.
            TestSuiteHelper.AddListItems(listId, totalNumber);

            // Call GetListItemChangesWithKnowledge with previous knowledge and specified RowLimit.
            syncKnowledge.syncKnowledge = result.listitems.Changes.MadeWithKnowledge.syncKnowledge;
            int expectRowLimit = 5;
            result = this.listswsAdapter.GetListItemChangesWithKnowledge(
                                            listId,
                                            null,
                                            null,
                                            null,
                                            expectRowLimit.ToString(),
                                            null,
                                            null,
                                            syncKnowledge,
                                            null);
            data = AdapterHelper.ExtractData(result.listitems.data.Any);

            // If the RowLimit is specified, the return items will restricted by this element.
            this.Site.Assert.AreEqual<int>(
                            expectRowLimit,
                            data.Rows.Count,
                            "The 5 items will be returned if the RowLimit value is 5 when calling GetListItemChangesWithKnowledge.");

            // If whether the RowLimit is specified or not, the server only return the changes made after knowledge
            // then R1114 can be captured.
            this.Site.CaptureRequirementIfAreEqual<int>(
                        expectRowLimit,
                        data.Rows.Count,
                        1114,
                        @"[In GetListItemChangesWithKnowledge]If specified, the response will include changes made to list items after the knowledge data structure was retrieved, subject to the row limit restrictions just described.");

            bool isMoreChange = string.Compare("True", result.listitems.Changes.MoreChanges, StringComparison.OrdinalIgnoreCase) == 0;
            this.Site.Assert.IsTrue(
                            isMoreChange,
                            "If there are more changes, the server will response attribute MoreChanges 'True', but actual value is {0}",
                            result.listitems.Changes.MoreChanges);

            // If the attribute MoreChange is "True", then R1120 and R1131 can be captured.
            this.Site.CaptureRequirementIfIsTrue(
                        isMoreChange,
                        1120,
                        @"[In GetListItemChangesWithKnowledge]The Changes element in the response MUST include the attribute MoreChanges set to ""TRUE"" to indicate that protocol clients can make another call to GetListItemChangesWithKnowledge by using the new knowledge from the most recent response to retrieve subsequent changes.");
            this.Site.CaptureRequirementIfIsTrue(
                        isMoreChange,
                        1131,
                        @"[In GetListItemChangesWithKnowledgeResponse][Attribute of MoreChanges]The Changes element in the response MUST include the attribute MoreChanges set to ""TRUE"" if more changes are known to the protocol server than were returned to the protocol client.");
            this.Site.CaptureRequirementIfIsTrue(
                        !isMoreChangeIncludedWithoutKnowledge && isMoreChange,
                        1133,
                        @"[In GetListItemChangesWithKnowledgeResponse][Attribute of Morechanges]MoreChanges MUST be included in the result only if the knowledge parameter was specified by the protocol client in the request.");

            // Add one field to make schema changed. 
            TestSuiteHelper.AddFieldsToList(
                                listId,
                                new List<string> { TestSuiteHelper.GetUniqueFieldName() },
                                new List<string> { "Text" },
                                new List<string> { null });

            // Retrieve the knowledge again.
            syncKnowledge.syncKnowledge = result.listitems.Changes.MadeWithKnowledge.syncKnowledge;
            result = this.listswsAdapter.GetListItemChangesWithKnowledge(
                                            listId,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            syncKnowledge,
                                            null);

            bool isSchemaChange = string.Compare("True", result.listitems.Changes.SchemaChanged, StringComparison.OrdinalIgnoreCase) == 0;
            this.Site.Assert.IsTrue(
                            isSchemaChange,
                            "If there are schema changed, the server will response attribute SchemaChanged 'True', but actual value is {0}",
                            result.listitems.Changes.SchemaChanged);

            this.Site.CaptureRequirementIfIsTrue(
                            isSchemaChange,
                            1134,
                            @"[In GetListItemChangesWithKnowledgeResponse][Attribute of SchemaChanged]The SchemaChanged attribute MUST be set to ""TRUE"" if there have schema changes made to the list.");
        }
S03_OperationOnListItem