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

MSLISTSWS_S03_TC65_GetVersionCollection_SucceedWithValidGUIDListName() private method

        public void MSLISTSWS_S03_TC65_GetVersionCollection_SucceedWithValidGUIDListName()
        {
            #region Invoke AddList operation to create a new generic list.
            string strList_GUID = TestSuiteHelper.CreateList((int)TemplateType.Generic_List);
            #endregion

            #region Add a new "Required" field in the generic list
            string strNewRequiredField = TestSuiteHelper.GetUniqueFieldName();
            TestSuiteHelper.AddFieldsToList(
                                                       strList_GUID,
                                                       new List<string> { strNewRequiredField },
                                                       new List<string> { "Counter" },
                                                       true,
                                                       new List<string> { null });
            #endregion

            #region Add a new list item in the generic list with a valid value for the "Required" field
            Dictionary<string, string> fieldNameValuePairs = new Dictionary<string, string>();
            Random randomIntValue = new Random();
            string fieldValue = randomIntValue.Next().ToString();
            fieldNameValuePairs.Add(strNewRequiredField, fieldValue);
            UpdateListItemsUpdates listItemUpdates_1 = TestSuiteHelper.CreateUpdateListItems(
                                                        new List<MethodCmdEnum> { MethodCmdEnum.New },
                                                        new List<Dictionary<string, string>> { fieldNameValuePairs });

            UpdateListItemsResponseUpdateListItemsResult updateListItemsResult = null;
            updateListItemsResult = this.listswsAdapter.UpdateListItems(strList_GUID, listItemUpdates_1);
            #endregion

            #region Get the list item ID in the response of UpdateListItems
            string strListItemID = null;
            Site.Assert.IsNotNull(updateListItemsResult, "The Object \"updateListItemsResult\" is null! ");
            Site.Assert.IsNotNull(updateListItemsResult.Results, "The Object \"updateListItemsResult.Results\" is null! ");
            Site.Assert.IsTrue(updateListItemsResult.Results.Length >= 1, "There is no result in the result array!");
            UpdateListItemsResponseUpdateListItemsResultResult[] arrRresults = updateListItemsResult.Results;
            Site.Assert.IsNotNull(arrRresults[0].Any, "The Object \"arrRresults[0].Any\" is null! ");
            XmlElement[] rowItems = arrRresults[0].Any;
            System.Data.DataTable dataTable = AdapterHelper.ExtractData(rowItems);
            Site.Assert.IsNotNull(dataTable, "The Object \"dataTable\" is null! ");
            Site.Assert.IsNotNull(dataTable.Rows, "The Object \"dataTable.Rows\" is null! ");
            Site.Assert.IsTrue(dataTable.Rows.Count >= 1, "There is no list item in the result!");
            strListItemID = dataTable.Rows[0]["ows_ID"].ToString();
            Site.Assert.IsNotNull(strListItemID, "Failed to get the list item ID in the response of UpdateListItems!");
            #endregion

            #region Invoke GetVersionCollection operation use the list title as the value of element listName.
            GetVersionCollectionResponseGetVersionCollectionResult getVersionCollectionResult = null;
            getVersionCollectionResult = this.listswsAdapter.GetVersionCollection(strList_GUID, strListItemID, strNewRequiredField);
            #endregion

            #region Capture Requirements #762 #771

            // If protocol SUT returns the successful response of GetVersionCollection, capture requirements #762.
            Site.Log.Add(
                         LogEntryKind.Debug,
                         "The actual value: getVersionResult[{0}] for requirement #R762",
                         null == getVersionCollectionResult ? "null" : "Not null");

            Site.CaptureRequirementIfIsNotNull(
                getVersionCollectionResult,
                762,
                @"[In GetVersionCollection operation] If the specified strListID is a valid GUID and corresponds to "
                + "the identification of a list on the site, use that list.");

            // If protocol SUT returns version collections element in the successful response of GetVersionCollection, 
            // capture requirements #771.
            bool isCaptureR771 = false;
            Site.Assert.IsNotNull(getVersionCollectionResult, "The Object \"getVersionCollectionResult\" is null! ");
            Site.Assert.IsNotNull(getVersionCollectionResult.Versions, "The Object \"getVersionCollectionResult.Versions\" is null! ");
            if (getVersionCollectionResult.Versions.Length > 0)
            {
                isCaptureR771 = true;
            }

            Site.Log.Add(
                          LogEntryKind.Debug,
                          "The actual value: getVersionCollectionResult.Versions.Length[{0}] for requirement #R771",
                           getVersionCollectionResult.Versions.Length);

            Site.CaptureRequirementIfIsTrue(
                isCaptureR771,
                771,
                @"[In GetVersionCollection operation] If the protocol client passes valid input parameters, the protocol "
                + "server MUST return the version collection.");

            #endregion
        }
S03_OperationOnListItem