public void MSLISTSWS_S03_TC35_GetListItemChanges_SpecifiedTimespan()
{
string listName = TestSuiteHelper.GetUniqueListName();
string listId = TestSuiteHelper.CreateList(listName);
// Insert items.
TestSuiteHelper.AddListItems(listId, 2);
// Get the time spans. Using this token will exclude the above two changes
// and only the following subsequent changes can be seen.
GetListItemChangesResponseGetListItemChangesResult getListItemChangesResult =
this.listswsAdapter.GetListItemChanges(listId, null, null, null);
Site.CaptureRequirementIfAreEqual<int>(
2,
getListItemChangesResult.listitems.data.Length,
643,
@"[In GetListItemChanges operation] [In GetListItemChanges element] [In since field] If this value[since] is null, the protocol server MUST return all list items in the list.");
string timeSpan = getListItemChangesResult.listitems.TimeStamp;
// Insert items again
TestSuiteHelper.AddListItems(listId, 2);
getListItemChangesResult = this.listswsAdapter.GetListItemChanges(listId, null, timeSpan, null);
// According to Open Specification, the number of data element is 2.
Site.Debug.AreEqual<int>(
2,
getListItemChangesResult.listitems.data.Length,
"The number data element in the GetListItemChanges should be 2");
// According to Open Specification, the first data should contain all the changes after the
// specified since change token.
DataTable data = AdapterHelper.ExtractData(getListItemChangesResult.listitems.data[0].Any);
bool isAfterSince = true;
foreach (DataRow row in data.Rows)
{
isAfterSince = isAfterSince && (DateTime.Parse(timeSpan, CultureInfo.InvariantCulture) <= DateTime.Parse(row["ows_Created"].ToString(), CultureInfo.InvariantCulture));
}
Site.CaptureRequirementIfIsTrue(
isAfterSince,
1861,
@"The first rs:data element contains all the inserted and updated list items that have "
+ "occurred subsequent to the specified since parameter.");
// According to the Open Specification, the first data should contain all the list items.
// The total number items should be 4, because the two items are inserted twice.
Site.CaptureRequirementIfAreEqual<int>(
4,
int.Parse(getListItemChangesResult.listitems.data[1].ItemCount),
1862,
@"[GetListItemChangesResponse]The second rs:data element contains all of the list items "
+ "currently in the list.");
// Call GetList operation to get all the list field.
GetListResponseGetListResult listResult;
listResult = this.listswsAdapter.GetList(listId);
bool startWithOwsFirst, startWithOwsSecond;
bool correspondNamesFirst, correspondNamesSecond;
DataTable firstData = AdapterHelper.ExtractData(getListItemChangesResult.listitems.data[0].Any);
DataTable secondData = AdapterHelper.ExtractData(getListItemChangesResult.listitems.data[1].Any);
ValidateOwsPrefixAndAttributeName(
firstData,
listResult,
out startWithOwsFirst,
out correspondNamesFirst);
ValidateOwsPrefixAndAttributeName(
secondData,
listResult,
out startWithOwsSecond,
out correspondNamesSecond);
// If both the data element's z:row attribute names start with ows_, capture the requirement R1863.
Site.CaptureRequirementIfIsTrue(
startWithOwsFirst && startWithOwsSecond,
1863,
@"[GetListItemChangesResponse]The names of the attributes containing the list "
+ @"item data in inner z:row elements are prefixed by ""ows_"".");
// If both the data element's z:row attribute names are consistent with fields returned from GetList operation,
// capture R2370 and R2256.
Site.CaptureRequirementIfIsTrue(
correspondNamesFirst && correspondNamesSecond,
2370,
@"[GetListItemChangesResponse]The names of the attributes containing the list "
+ "item data in inner z:row elements correspond to the Name attribute in the Field "
+ "elements of GetList.");
Site.CaptureRequirementIfIsTrue(
correspondNamesFirst && correspondNamesSecond,
2256,
@"[DataDefinition]The names of the attributes of this element correspond to the "
+ "names of fields in the list.");
}