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

MSLISTSWS_S04_TC01_AddAttachment_ContentLengthZero() private method

        public void MSLISTSWS_S04_TC01_AddAttachment_ContentLengthZero()
        {
            #region Create a new list

            bool createListSucceeded = false;
            string listName = TestSuiteHelper.GetUniqueListName();
            string listGuid = TestSuiteHelper.CreateList(listName);
            createListSucceeded = !string.IsNullOrEmpty(listGuid);
            Site.Assert.IsTrue(createListSucceeded, "MSLISTSWS_S04_TC01_AddAttachment_ContentLenghZero, created a new list successfully.");
            #endregion

            #region Add a list item

            List<string> listItemIds = TestSuiteHelper.AddListItems(listGuid, 1);
            Site.Assert.IsNotNull(listItemIds, "Called AddListItems successfully.");

            #endregion

            #region Call the AddAttachment with the content length 0

            bool addAttachmentFail = false;
            string errorCode = null;
            try
            {
                // Call the AddAttachment with the content length 0
                string fileName = Common.GetConfigurationPropertyValue("AttachmentName", this.Site);
                byte[] attachment = new byte[0];
                this.listswsAdapterInstance.AddAttachment(listName, listItemIds[0], fileName, attachment);
            }
            catch (SoapException exp)
            {
                errorCode = TestSuiteHelper.GetErrorCode(exp);
                addAttachmentFail = true;
            }

            Site.Assert.IsTrue(addAttachmentFail, "MSLISTSWS_S04_TC01_AddAttachment_ContentLenghZero, calling AddAttachmet with content length 0 fails.");

            // Capture R299 if the error code 0x8007000d is returned.
            Site.CaptureRequirementIfAreEqual<string>(
                "0x8007000d",
                errorCode,
                299,
                @"[In AddAttachment] If the protocol client requests to add an attachment of content length zero, the protocol server MUST return a SOAP fault with error code 0x8007000d.");
            #endregion
        }