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

MSLISTSWS_S03_TC61_GetVersionCollection_InvalidParameterWithEmptyListItemID() private method

        public void MSLISTSWS_S03_TC61_GetVersionCollection_InvalidParameterWithEmptyListItemID()
        {
            #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 });

            // Invoke UpdateListItems operation to make a change.
            this.listswsAdapter.UpdateListItems(strList_GUID, listItemUpdates_1);
            #endregion

            #region Invoke GetVersionCollection operation, set the value of strListItemID to null or empty string.

            bool isSoapFauleExistedForNullListItemID = false;
            string errorCodeForNullListItemID = string.Empty;
            string strErrorCode = string.Empty;
            string strErrorString = string.Empty;
            try
            {
                this.listswsAdapter.GetVersionCollection(strList_GUID, null, strNewRequiredField);
            }
            catch (SoapException soapEx)
            {
                isSoapFauleExistedForNullListItemID = true;
                errorCodeForNullListItemID = TestSuiteHelper.GetErrorCode(soapEx);
            }

            bool isSoapFauleExistedForEmptyListItemID = false;
            string errorCodeForEmptyListItemID = string.Empty;
            try
            {
                this.listswsAdapter.GetVersionCollection(strList_GUID, string.Empty, strNewRequiredField);
            }
            catch (SoapException soapEx)
            {
                isSoapFauleExistedForEmptyListItemID = true;
                errorCodeForEmptyListItemID = TestSuiteHelper.GetErrorCode(soapEx);
            }
            #endregion

            #region Capture Requirements #3020 #3021

            Site.Log.Add(
              LogEntryKind.Debug,
              "The actual value: errorCodeForEmptyListItemID[{0}],errorCodeForNullListItemID[{1}] for requirement #R3020, #R3021",
              string.IsNullOrEmpty(errorCodeForEmptyListItemID) ? "NullOrEmpty" : strErrorCode,
              string.IsNullOrEmpty(errorCodeForNullListItemID) ? "NullOrEmpty" : strErrorCode);

            Site.CaptureRequirementIfIsTrue(
                isSoapFauleExistedForNullListItemID && isSoapFauleExistedForEmptyListItemID
                && "0x82000001".Equals(errorCodeForNullListItemID, StringComparison.OrdinalIgnoreCase)
                && "0x82000001".Equals(errorCodeForEmptyListItemID, StringComparison.OrdinalIgnoreCase),
                3020,
                @"[In GetVersionCollection operation] If the strListItemID is null or an empty string, "
                + "the protocol server MUST return a SOAP fault with error code 0x82000001.");

            Site.CaptureRequirementIfIsTrue(
                isSoapFauleExistedForNullListItemID && isSoapFauleExistedForEmptyListItemID
                && "0x82000001".Equals(errorCodeForNullListItemID, StringComparison.OrdinalIgnoreCase)
                && "0x82000001".Equals(errorCodeForEmptyListItemID, StringComparison.OrdinalIgnoreCase),
                3021,
                @"[In GetVersionCollection operation] [If the strListItemID is null or an empty string, "
                + "the protocol server MUST return a SOAP fault with error code 0x82000001.] "
                + "This indicates that the parameter strListItemID is missing or invalid.");

            #endregion

            #region Invoke GetVersionCollection operation, set strListItemID to a negative value.

            try
            {
                this.listswsAdapter.GetVersionCollection(strList_GUID, "-12", strNewRequiredField);
            }
            catch (SoapException soapEx)
            {
                strErrorCode = TestSuiteHelper.GetErrorCode(soapEx);
                strErrorString = TestSuiteHelper.GetErrorString(soapEx);
            }
            #endregion

            #region Capture Requirements #7662 #7663

            if (Common.IsRequirementEnabled(7660, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R7662");

                // Verify MS-LISTSWS requirement: MS-LISTSWS_R7662
                bool isVerifyR7662 = string.Equals(strErrorCode, "0x81020014");

                Site.CaptureRequirementIfIsTrue(
                    isVerifyR7662,
                    7662,
                    @"Implementation does return a SOAP fault with error code 0x81020014 when strListItemID is a negative value.(Microsoft® SharePoint® Foundation 2010 and above follow this behavior.) ");
            }

            if (Common.IsRequirementEnabled(7661, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R7663");

                // Verify MS-LISTSWS requirement: MS-LISTSWS_R7663
                bool isVerifyR7663 = string.Equals(strErrorCode, null) && string.Equals(strErrorString, AdapterHelper.OutOfRange);

                Site.CaptureRequirementIfIsTrue(
                    isVerifyR7663,
                    7663,
                    @"[In Appendix B: Product Behavior] Implementation does return a SOAP fault with no error code and the error string ""Value does not fall within the expected range."" when strListItemID is a negative value.(Windows® SharePoint® Services 3.0 follows this behavior)");
            }

            #endregion

            #region Invoke GetVersionCollection operation, set strListItemID to zero.
            bool isCaptureR7664 = false;
            bool isCaptureR7665 = false;
            try
            {
                this.listswsAdapter.GetVersionCollection(strList_GUID, "0", strNewRequiredField);
            }
            catch (SoapException soapEx)
            {
                strErrorCode = TestSuiteHelper.GetErrorCode(soapEx);
                strErrorString = TestSuiteHelper.GetErrorString(soapEx);
                if (strErrorCode == null)
                {
                    isCaptureR7664 = true;
                    isCaptureR7665 = string.Equals(strErrorString, AdapterHelper.OutOfRange);
                }
                else
                {
                    isCaptureR7664 = false;
                    isCaptureR7665 = false;
                    string strCaseFail_Info = string.Format("CaseFail: The actual error code is {0}, but the expected error code is null!", strErrorCode);
                    Site.Log.Add(LogEntryKind.TestFailed, strCaseFail_Info);
                }
            }
            #endregion

            #region Capture Requirements #7664 #7665

            if (Common.IsRequirementEnabled(7660, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R7664");

                Site.CaptureRequirementIfIsTrue(
                    isCaptureR7664,
                    7664,
                    @"Implementation does return a SOAP fault with no error code when strListItemID is zero.(Microsoft® SharePoint® Foundation 2010 and above follow this behavior.)");
            }

            if (Common.IsRequirementEnabled(7661, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R7665");

                Site.CaptureRequirementIfIsTrue(
                    isCaptureR7665,
                    7665,
                    @"[In Appendix B: Product Behavior] Implementation does return a SOAP fault with no error code and the error string ""Value does not fall within the expected range."" when strListItemID is zero. (Windows® SharePoint® Services 3.0 follows this behavior)");
            }

            #endregion

            #region Invoke GetVersionCollection operation, set strListItemID to an invalid positive value.

            bool isCaptureR7666 = false;
            bool isCaptureR7667 = false;
            try
            {
                this.listswsAdapter.GetVersionCollection(strList_GUID, "9", strNewRequiredField);
            }
            catch (SoapException soapEx)
            {
                strErrorCode = TestSuiteHelper.GetErrorCode(soapEx);
                strErrorString = TestSuiteHelper.GetErrorString(soapEx);
                if (strErrorCode == null)
                {
                    isCaptureR7666 = true;
                    isCaptureR7667 = string.Equals(strErrorString, AdapterHelper.OutOfRange);
                }
                else
                {
                    isCaptureR7666 = false;
                    isCaptureR7667 = false;
                    string strCaseFail_Info = string.Format("CaseFail: The actual error code is {0}, but the expected error code is null!", strErrorCode);
                    Site.Log.Add(LogEntryKind.TestFailed, strCaseFail_Info);
                }
            }

            #endregion

            #region Capture Requirements #7666 #7667

            if (Common.IsRequirementEnabled(7660, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R7666");

                Site.CaptureRequirementIfIsTrue(
                    isCaptureR7666,
                    7666,
                    @"Implementation does return a SOAP fault with no error code when strListItemID is a positive value that does not correspond to a list item in a specified list on the site.(Microsoft® SharePoint® Foundation 2010 and above follow this behavior.) ");
            }

            if (Common.IsRequirementEnabled(7661, this.Site))
            {
                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R7667");

                Site.CaptureRequirementIfIsTrue(
                    isCaptureR7667,
                    7667,
                    @"[In Appendix B: Product Behavior] Implementation does return a SOAP fault with no error code and the error string ""Value does not fall within the expected range."" when strListItemID is a positive value that does not correspond to a list item in a specified list on the site. (Windows® SharePoint® Services 3.0 follows this behavior)");
            }

            #endregion
        }
S03_OperationOnListItem