public void MSLISTSWS_S01_TC19_GetList_Succeed() { string listName = TestSuiteHelper.GetUniqueListName(); bool addListSucceeded = false; IMS_LISTSWSSUTControlAdapter sutControlAdapter = this.Site.GetAdapter<IMS_LISTSWSSUTControlAdapter>(); // Call GetListItems to retrieve details about "User Information List" items string userInfoListName = Common.GetConfigurationPropertyValue("UserInfoListName", this.Site); GetListItemsQuery query = new GetListItemsQuery(); query.Query = new CamlQueryRoot(); query.Query.OrderBy = new OrderByDefinition(); GetListItemsResponseGetListItemsResult getListItemsResult = null; getListItemsResult = this.listswsAdapter.GetListItems( userInfoListName, null, query, null, null, null, null); // extract a row element to a DataTable, it is used for "z:row" data System.Data.DataTable data = AdapterHelper.ExtractData(getListItemsResult.listitems.data.Any); int listItemsCount = data.Rows.Count; Dictionary<string, string> userList = new Dictionary<string, string>(); string columnName = string.Format("{0}{1}", AdapterHelper.PrefixOws, "Name"); for (int i = 0; i < listItemsCount; i++) { userList.Add(Convert.ToString(data.Rows[i][AdapterHelper.PrefixOws + AdapterHelper.FieldIDName]), Convert.ToString(data.Rows[i][columnName])); } // Get Presence and RecycleBinEnable value of WebApp. bool presenceEnabled = sutControlAdapter.GetWebAppPresence(); bool recycleBinEnable = sutControlAdapter.GetWebAppRecycleBin(); try { // Add a Generic list. int templateId = (int)TemplateType.Generic_List; AddListResponseAddListResult addResult = this.listswsAdapter.AddList(listName, string.Empty, templateId); addListSucceeded = addResult != null && addResult.List != null && !string.IsNullOrEmpty(addResult.List.ID); this.Site.Assert.IsTrue(addListSucceeded, "Test suite should add the list successfully."); int waitTime = Common.GetConfigurationPropertyValue<int>("WaitTime", this.Site); int retryCount = Common.GetConfigurationPropertyValue<int>("RetryCount", this.Site); GetListResponseGetListResult getResult = null; while (retryCount > 0) { // Set Presence and RecycleBinEnable value to True. sutControlAdapter.SetWebAppPresence(true); System.Threading.Thread.Sleep(10000); sutControlAdapter.SetWebAppRecycleBin(true); System.Threading.Thread.Sleep(10000); // Call method GetList to get the list from server and check Presence and RecycleBinEnable value. getResult = this.listswsAdapter.GetList(addResult.List.ID); if (bool.Parse(getResult.List.RegionalSettings.Presence) && bool.Parse(getResult.List.ServerSettings.RecycleBinEnabled)) { break; } retryCount--; System.Threading.Thread.Sleep(waitTime); } Site.Assert.IsTrue(bool.Parse(getResult.List.RegionalSettings.Presence), "Presence in ListDefinitionSchema should be true after enable it."); Site.Assert.IsTrue(bool.Parse(getResult.List.ServerSettings.RecycleBinEnabled), "RecycleBinEnabled in ListDefinitionSchema should be true after enable it."); // Verify R1381 bool isContainInUserList = userList.ContainsKey(getResult.List.Author); Site.Assert.IsTrue(isContainInUserList, "The user identifier doesn't contain in the user information list."); string currentUser = string.Empty; string currentUserDomain = Common.GetConfigurationPropertyValue("Domain", this.Site); if (currentUserDomain.Contains(".")) { currentUser = currentUserDomain.Substring(0, currentUserDomain.IndexOf(".", StringComparison.OrdinalIgnoreCase)) + "\\" + Common.GetConfigurationPropertyValue("UserName", this.Site); } else { currentUser = currentUserDomain + "\\" + Common.GetConfigurationPropertyValue("UserName", this.Site); } // On O15 Farm, if the identity of the application pool is that of a particular administrator or if the administrator logs in as the farm account // or the application pool account, then SharePoint will show that person as System Account(SHAREPOINT\system). // So if the list author is System Account, it is the create user and the isCreateUser variable should be "True". bool isCreateUser = currentUser.Equals(userList[getResult.List.Author], StringComparison.CurrentCultureIgnoreCase) || currentUser.Equals(userList[getResult.List.Author].Substring(userList[getResult.List.Author].IndexOf('|') + 1), StringComparison.CurrentCultureIgnoreCase) || userList[getResult.List.Author].Equals("SHAREPOINT\\system", StringComparison.CurrentCultureIgnoreCase); Site.CaptureRequirementIfIsTrue( isContainInUserList && isCreateUser, 1381, @"[ListDefinitionCT.Author:] The user identifier of the user who created the list, which is contained in the user information list."); // If the value of Presence equals to the value set by sutControlAdapter(true), capture R1427. Site.CaptureRequirementIfIsTrue( bool.Parse(getResult.List.RegionalSettings.Presence), 1427, @"[ListDefinitionSchema.Presence:] Specifies that presence is enabled if set to True; [otherwise Presence is not enabled.]"); // If the value of RecycleBinEnabled equals to the value set by sutControlAdapter(true), capture R1429. Site.CaptureRequirementIfIsTrue( bool.Parse(getResult.List.ServerSettings.RecycleBinEnabled), 1429, @"[ListDefinitionSchema.RecycleBinEnabled: ]Specifies that the Recycle Bin is enabled if set to True;[ otherwise, the Recycle Bin is not enabled.]"); retryCount = Common.GetConfigurationPropertyValue<int>("RetryCount", this.Site); while (retryCount > 0) { // Set Presence and RecycleBinEnable value to false. sutControlAdapter.SetWebAppPresence(false); System.Threading.Thread.Sleep(10000); sutControlAdapter.SetWebAppRecycleBin(false); System.Threading.Thread.Sleep(10000); // Call method GetList to get the list from server and check Presence and RecycleBinEnable value. getResult = this.listswsAdapter.GetList(addResult.List.ID); if (!bool.Parse(getResult.List.RegionalSettings.Presence) && !bool.Parse(getResult.List.ServerSettings.RecycleBinEnabled)) { break; } retryCount--; System.Threading.Thread.Sleep(waitTime); } Site.Assert.IsFalse(bool.Parse(getResult.List.RegionalSettings.Presence), "Presence in ListDefinitionSchema should be false after disable it."); Site.Assert.IsFalse(bool.Parse(getResult.List.ServerSettings.RecycleBinEnabled), "RecycleBinEnabled in ListDefinitionSchema should be false after disable it."); // If the value of Presence equals to the value set by sutControlAdapter(false), capture R2249. Site.CaptureRequirementIfIsFalse( bool.Parse(getResult.List.RegionalSettings.Presence), 2249, @"ListDefinitionSchema.Presence: [Specifies that presence is enabled if set to True; ]otherwise Presence is not enabled."); // If the value of RecycleBinEnabled equals to the value set by sutControlAdapter(false), capture R2248. Site.CaptureRequirementIfIsFalse( bool.Parse(getResult.List.ServerSettings.RecycleBinEnabled), 2248, @"ListDefinitionSchema.RecycleBinEnabled: [Specifies that the Recycle Bin is enabled if set to True;] otherwise, the Recycle Bin is not enabled."); // Call method GetList to get the list from server. // If the GetListResponse is returned, then capture R555 and R557. getResult = this.listswsAdapter.GetList(addResult.List.ID); Site.CaptureRequirementIfIsNotNull( getResult, 555, @"[In GetList operation] If the specified listName is a valid GUID and corresponds to the identification of a list on the site, the protocol server MUST return a GetListResponse element."); GetListResponseGetListResult getTitleResult = this.listswsAdapter.GetList(addResult.List.Title); Site.CaptureRequirementIfIsNotNull( getTitleResult, 557, @"[In GetList operation] If the specified listName does not correspond to the identification of a list on the site, check if the listName corresponds to the list title of a list on the site, and if so the protocol server MUST return a GetListResponse element."); // Call method GetList with ListName does not have a valid GUID. // If the GetListResponse is returned, then capture R556. GetListResponseGetListResult getResultInvalidName = this.listswsAdapter.GetList(listName); Site.CaptureRequirementIfIsNotNull( getResultInvalidName, 556, @"[In GetList operation] If the specified listName is not a valid GUID, check if the listName corresponds to the list title of a list on the site, and if so the protocol server MUST return a GetListResponse element."); } finally { // Restore Presence and RecycleBinEnable settings for WebApp. sutControlAdapter.SetWebAppPresence(presenceEnabled); System.Threading.Thread.Sleep(10000); sutControlAdapter.SetWebAppRecycleBin(recycleBinEnable); System.Threading.Thread.Sleep(10000); if (addListSucceeded) { this.listswsAdapter.DeleteList(listName); } } }
/// <summary> /// This operation is used to retrieve details about list items in a list that satisfy specified criteria. /// </summary> /// <param name="listName">The name of the list from which item changes will be got</param> /// <param name="viewName">The GUID refers to a view of the list</param> /// <param name="query">The query to determine which records from the list are to be returned </param> /// <param name="viewFields">Specifies which fields of the list item should be returned</param> /// <param name="rowLimit">Specifies the maximum number of rows of data to return in the response</param> /// <param name="queryOptions">Specifies various options for modifying the query</param> /// <param name="webID">The GUID of the site that contains the list. If not specified, the default Web site based on the SOAP request is used</param> /// <returns>Get list item result</returns> public GetListItemsResponseGetListItemsResult GetListItems(string listName, string viewName, GetListItemsQuery query, CamlViewFields viewFields, string rowLimit, CamlQueryOptions queryOptions, string webID) { this.Site.Assert.IsNotNull(this.listsProxy, "The Proxy instance should not be NULL. If assert failed, the adapter need to be initialized"); GetListItemsResponseGetListItemsResult result = null; try { result = this.listsProxy.GetListItems(listName, viewName, query, viewFields, rowLimit, queryOptions, webID); // Verify the requirements of the GetListItems operation. this.VerifyGetListItemsOperation(result, queryOptions, viewFields); // Verify the requirements of the transport. this.VerifyTransportRequirements(); } catch (XmlSchemaValidationException exp) { // Log the errors and warnings this.LogSchemaValidationErrors(); this.Site.Assert.Fail(exp.Message); } catch (SoapException) { this.VerifySoapExceptionFault(); throw; } return result; }
/// <remarks/> public void GetListItemsAsync(string listName, string viewName, GetListItemsQuery query, CamlViewFields viewFields, string rowLimit, CamlQueryOptions queryOptions, string webID) { this.GetListItemsAsync(listName, viewName, query, viewFields, rowLimit, queryOptions, webID, null); }
/// <remarks/> public void GetListItemsAsync(string listName, string viewName, GetListItemsQuery query, CamlViewFields viewFields, string rowLimit, CamlQueryOptions queryOptions, string webID, object userState) { if ((this.GetListItemsOperationCompleted == null)) { this.GetListItemsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetListItemsOperationCompleted); } this.InvokeAsync("GetListItems", new object[] { listName, viewName, query, viewFields, rowLimit, queryOptions, webID}, this.GetListItemsOperationCompleted, userState); }
/// <remarks/> public System.IAsyncResult BeginGetListItems(string listName, string viewName, GetListItemsQuery query, CamlViewFields viewFields, string rowLimit, CamlQueryOptions queryOptions, string webID, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetListItems", new object[] { listName, viewName, query, viewFields, rowLimit, queryOptions, webID}, callback, asyncState); }
public GetListItemsResponseGetListItemsResult GetListItems(string listName, string viewName, GetListItemsQuery query, CamlViewFields viewFields, string rowLimit, CamlQueryOptions queryOptions, string webID) { object[] results = this.Invoke("GetListItems", new object[] { listName, viewName, query, viewFields, rowLimit, queryOptions, webID}); return ((GetListItemsResponseGetListItemsResult)(results[0])); }
public void MSLISTSWS_S03_TC56_GetListItems_WithoutPaging() { // Create a list. string listId = TestSuiteHelper.CreateList(); // Insert 10 items. List<string> addedItems = TestSuiteHelper.AddListItems(listId, 10); // Sort the list to make sure order by Ascending. addedItems = addedItems.OrderBy<string, int>(key => Convert.ToInt32(key)).ToList(); // Create Query element to make the z:row ordered by OWS_ID Ascending. GetListItemsQuery query = new GetListItemsQuery(); query.Query = new CamlQueryRoot(); query.Query.OrderBy = new OrderByDefinition(); query.Query.OrderBy.FieldRef = new FieldRefDefinitionOrderBy[1]; query.Query.OrderBy.FieldRef[0] = new FieldRefDefinitionOrderBy(); query.Query.OrderBy.FieldRef[0].Name = AdapterHelper.FieldIDName; query.Query.OrderBy.FieldRef[0].Ascending = "TRUE"; // Call the GetListItems excluding the paging. GetListItemsResponseGetListItemsResult result = null; result = this.listswsAdapter.GetListItems( listId, null, query, null, null, null, null); string columnNameId = AdapterHelper.PrefixOws + AdapterHelper.FieldIDName; DataTable data = AdapterHelper.ExtractData(result.listitems.data.Any); // If the returned z:row count number equals to the all item number // and the returned first z:row ows_ID equals the first addedItems element, // it will be sure that it starts from the first index. bool isStartFirstIndexExcludePaging = data.Rows.Count == addedItems.Count && Convert.ToString(data.Rows[0][columnNameId]) == addedItems[0]; Site.Assert.IsTrue( isStartFirstIndexExcludePaging, "When paging element is not specified, the list items returned start from the beginning of the list."); // Call GetListItems with empty paging CamlQueryOptions options = new CamlQueryOptions(); options.QueryOptions = new CamlQueryOptionsQueryOptions(); options.QueryOptions.Paging = new CamlQueryOptionsQueryOptionsPaging(); result = this.listswsAdapter.GetListItems( listId, null, query, null, null, options, null); // If the returned z:row count number equals to the all item number // and the returned first z:row ows_ID equals the first addedItems element, // it will be sure that it starts from the first index. data = AdapterHelper.ExtractData(result.listitems.data.Any); bool isStartFirstIndexEmptyPaging = data.Rows.Count == addedItems.Count && Convert.ToString(data.Rows[0][columnNameId]) == addedItems[0]; Site.Assert.IsTrue( isStartFirstIndexEmptyPaging, "When paging element is empty, the list items returned start from the beginning of the list."); Site.CaptureRequirementIfIsTrue( isStartFirstIndexEmptyPaging && isStartFirstIndexExcludePaging, 1251, @"[Paging]If this element[Paging] is left empty or excluded, the list items returned start from the beginning of the list."); }
public void MSLISTSWS_S03_TC55_GetListItems_WithPaging() { // Create a list. string listId = TestSuiteHelper.CreateList(); // Insert 10 item. List<string> addedItems = TestSuiteHelper.AddListItems(listId, 10); // Sorted the list to make sure order by Ascending. addedItems = addedItems.OrderBy<string, int>(key => Convert.ToInt32(key)).ToList(); // Create Query element to make the z:row ordered by OWS_ID Ascending. GetListItemsQuery query = new GetListItemsQuery(); query.Query = new CamlQueryRoot(); query.Query.OrderBy = new OrderByDefinition(); query.Query.OrderBy.FieldRef = new FieldRefDefinitionOrderBy[1]; query.Query.OrderBy.FieldRef[0] = new FieldRefDefinitionOrderBy(); query.Query.OrderBy.FieldRef[0].Name = AdapterHelper.FieldIDName; query.Query.OrderBy.FieldRef[0].Ascending = "TRUE"; // Set the row limit. string rowLimit = "2"; // Call the GetListItems excluding the paging. GetListItemsResponseGetListItemsResult result = null; result = this.listswsAdapter.GetListItems( listId, null, query, null, rowLimit, null, null); // Call GetListItems with ListItemCollectionPositionNext which is got by previous call. CamlQueryOptions options = new CamlQueryOptions(); options.QueryOptions = new CamlQueryOptionsQueryOptions(); options.QueryOptions.Paging = new CamlQueryOptionsQueryOptionsPaging(); options.QueryOptions.Paging.ListItemCollectionPositionNext = result.listitems.data.ListItemCollectionPositionNext; result = this.listswsAdapter.GetListItems( listId, null, query, null, null, options, null); string columnNameId = AdapterHelper.PrefixOws + AdapterHelper.FieldIDName; DataTable data = AdapterHelper.ExtractData(result.listitems.data.Any); // If the returned first z:row ows_ID equals the next page's first addedItems element, // Then capture requirement R1252. bool isNextPage = Convert.ToString(data.Rows[0][columnNameId]) == addedItems[Convert.ToInt32(rowLimit)]; Site.CaptureRequirementIfIsTrue( isNextPage, 1252, @"[Paging]The protocol server MUST return the next page of data based on the " + "bookmark supplied."); }
public void MSLISTSWS_S03_TC53_GetListItems_ViewFields() { // Invoke AddList operation to create a new generic list. string strList_GUID = TestSuiteHelper.CreateList((int)TemplateType.Generic_List); // Invoke UpdateListItems operation to add one new list item in the new generic list. string validFieldName = Common.GetConfigurationPropertyValue("ListFieldText", this.Site); string fieldValue = TestSuiteHelper.GenerateRandomString(5); List<Dictionary<string, string>> insertItems = new List<Dictionary<string, string>>(1); List<MethodCmdEnum> insertCmds = new List<MethodCmdEnum>(1); Dictionary<string, string> insertItem = new Dictionary<string, string>(); insertItem.Add(validFieldName, fieldValue); insertItems.Add(insertItem); insertCmds.Add(MethodCmdEnum.New); // Construct the UpdateListItemsUpdates instance. UpdateListItemsUpdates updates = TestSuiteHelper.CreateUpdateListItems(insertCmds, insertItems, OnErrorEnum.Continue); // Call UpdateListItems to insert the item using List GUID. UpdateListItemsResponseUpdateListItemsResult addItemResult = null; addItemResult = this.listswsAdapter.UpdateListItems(strList_GUID, updates); Site.Assert.AreEqual<int>( 1, addItemResult.Results.Length, "The number of result element in the UpdateListItems response MUST be equal to the number of Method in the request."); DataTable addItemData = AdapterHelper.ExtractData(addItemResult.Results[0].Any); // Call GetListItems operation with empty ViewFields element. CamlViewFields emptyViewFields = new CamlViewFields(); emptyViewFields.ViewFields = new CamlViewFieldsViewFields(); GetListItemsResponseGetListItemsResult getListResult = null; getListResult = this.listswsAdapter.GetListItems(strList_GUID, null, null, emptyViewFields, null, null, null); DataTable getListData = AdapterHelper.ExtractData(getListResult.listitems.data.Any); // If all fields in GetListItems response exists in UpdateListItems response, capture R42. bool isR42Verified = true; foreach (DataColumn column in getListData.Columns) { isR42Verified = isR42Verified && addItemData.Columns.Contains(column.ColumnName); } this.Site.CaptureRequirementIfIsTrue( isR42Verified, 42, @"[In CamlViewFields] [ViewFields] An empty element <ViewFields /> specifies that all fields of the list item MUST be returned in the protocol server response."); // Get default view GUID. GetListAndViewResponseGetListAndViewResult getListAndView = null; getListAndView = this.listswsAdapter.GetListAndView(strList_GUID, string.Empty); Site.Assert.IsNotNull(getListAndView, "The object \"getListAndView\" should not be null !"); Site.Assert.IsNotNull(getListAndView.ListAndView, "The object \"getListAndView.ListAndView\" should not be null !"); Site.Assert.IsNotNull(getListAndView.ListAndView.View, "The object \"getListAndView.ListAndView.View\" should not be null !"); Site.Assert.IsNotNull(getListAndView.ListAndView.View.Name, "The object \"getListAndView.ListAndView.View.Name\" should not be null !"); string strViewGUID = getListAndView.ListAndView.View.Name; // Create query, viewFields, rowLimit, queryOptions parameters. GetListItemsQuery query = new GetListItemsQuery(); query.Query = new CamlQueryRoot(); query.Query.OrderBy = new OrderByDefinition(); query.Query.OrderBy.FieldRef = new FieldRefDefinitionOrderBy[1]; query.Query.OrderBy.FieldRef[0] = new FieldRefDefinitionOrderBy(); query.Query.OrderBy.FieldRef[0].Name = AdapterHelper.FieldIDName; query.Query.OrderBy.FieldRef[0].Ascending = "TRUE"; CamlViewFields viewFields = TestSuiteHelper.CreateViewFields(true, new List<string> { validFieldName }); string rowLimit = "1"; CamlQueryOptions queryOption = CreateDefaultCamlQueryOptions(); // Call GetListItems with default view GUID and valid query, viewFields, rowLimit, queryOptions parameters. GetListItemsResponseGetListItemsResult defaultViewResult = null; defaultViewResult = this.listswsAdapter.GetListItems(strList_GUID, strViewGUID, query, viewFields, rowLimit, queryOption, null); // Call GetListItems without viewName and with valid query, viewFields, rowLimit, queryOptions parameters. GetListItemsResponseGetListItemsResult nullViewResult = null; nullViewResult = this.listswsAdapter.GetListItems(strList_GUID, null, query, viewFields, rowLimit, queryOption, null); // If the same response returned, capture R2272. bool isSame = TestSuiteHelper.DeepCompare(defaultViewResult, nullViewResult); Site.CaptureRequirementIfIsTrue( isSame, 2272, @"If each of the query, viewFields, queryOptions, and rowLimit parameters are specified, the response of protocol server will be same even if viewName parameter are different."); // Call GetListItems operation with not empty ViewFields element. CamlViewFields viewFields1 = new CamlViewFields(); viewFields1.ViewFields = new CamlViewFieldsViewFields(); viewFields1.ViewFields.FieldRef = new CamlViewFieldsViewFieldsFieldRef[1]; viewFields1.ViewFields.FieldRef[0] = new CamlViewFieldsViewFieldsFieldRef(); viewFields1.ViewFields.FieldRef[0].Name = "Attachments"; GetListItemsResponseGetListItemsResult getListResultView1 = null; getListResultView1 = this.listswsAdapter.GetListItems(strList_GUID, null, null, viewFields1, null, null, null); DataTable getListData1 = AdapterHelper.ExtractData(getListResultView1.listitems.data.Any); bool isRR742001Verified = true; foreach (DataColumn column in getListData1.Columns) { if (column.ColumnName.Contains("Attachments")) { isRR742001Verified = false; break; } } CamlViewFields viewFields2 = new CamlViewFields(); viewFields2.ViewFields = new CamlViewFieldsViewFields(); viewFields2.ViewFields.FieldRef = new CamlViewFieldsViewFieldsFieldRef[1]; viewFields2.ViewFields.FieldRef[0] = new CamlViewFieldsViewFieldsFieldRef(); GetListItemsResponseGetListItemsResult getListResultView2 = null; getListResultView2 = this.listswsAdapter.GetListItems(strList_GUID, null, null, viewFields2, null, null, null); DataTable getListData2 = AdapterHelper.ExtractData(getListResultView2.listitems.data.Any); bool isRR742001Verified2 = true; foreach (DataColumn column in getListData2.Columns) { if (column.ColumnName.Contains("Attachments")) { isRR742001Verified2 = false; break; } } //Verify requirement: MS-LISTSWS_R742001001 if (Common.IsRequirementEnabled(742001001, this.Site)) { Site.CaptureRequirementIfIsFalse( isRR742001Verified && isRR742001Verified2, 742001001, @"[In Appendix B: Product Behavior] Implementation does not return the filed when the filed referenced in a FieldRef element of viewFields has no value filled. (Windows SharePoint Services 3.0 and above follow this behavior.)"); } }