Microsoft.Protocols.TestSuites.MS_LISTSWS.S04_OperationOnAttachment.MSLISTSWS_S04_TC09_DeleteAttachment_NonExistentListName_WSS3 C# (CSharp) Method

MSLISTSWS_S04_TC09_DeleteAttachment_NonExistentListName_WSS3() private method

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

            // Add a list
            #region Add a list
            string invalidListName = TestSuiteHelper.GetInvalidGuidAndNocorrespondString();
            string guid = TestSuiteHelper.CreateList();
            string expectederrorString = "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).";
            #endregion

            #region Initialize property value

            // Add one List item
            List<string> ids = TestSuiteHelper.AddListItems(guid, 1);

            #endregion

            #region Invoke AddAttachment and capture requirements
            string errorCode = string.Empty;
            string errorString = string.Empty;
            bool isSoapFaultGenerate = false;
            try
            {
                // Add an attachment using invalid GUID as listName parameter.
                string attchmentFileName = Common.GetConfigurationPropertyValue("AttachmentName", this.Site);
                byte[] attachmentFile = TestSuiteHelper.GetAttachmentContent(attchmentFileName);
                string attachmentUrl = this.listswsAdapterInstance.AddAttachment(guid, ids[0], attchmentFileName, attachmentFile);

                // Delete the attachment with an invalid list name.
                this.listswsAdapterInstance.DeleteAttachment(invalidListName, ids[0], attachmentUrl);
            }
            catch (SoapException exp)
            {
                isSoapFaultGenerate = true;
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                errorString = TestSuiteHelper.GetErrorString(exp);
            }

            this.Site.Assert.IsTrue(isSoapFaultGenerate, "There should be a soap fault generated for AddAttachment operation, when use invalid GUID.");
            this.Site.Assert.IsTrue(string.IsNullOrEmpty(errorCode), "The Soap exception contains error Code.");
            this.Site.Log.Add(LogEntryKind.Debug, "The actual error string:[{0}] \r\n for requirement #R2440", errorString);

            // If the error string equal to the "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."
            Site.Log.Add(
                LogEntryKind.Debug,
                "The actual value: errorString[{0}] for requirement #R2440",
                errorString);

            Site.CaptureRequirementIfIsTrue(
                        expectederrorString.IndexOf(errorString, StringComparison.OrdinalIgnoreCase) >= 0,
                        2440,
                        @"[In Appendix B: Product Behavior]Implementation does not return a SOAP fault with error code 0x82000006. (<38> Section 3.1.4.10: Windows SharePoint Services 3.0 return the following SOAP fault with no error code: ""GUID should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx)"".)");
            #endregion
        }