示例#1
0
        /// <summary>
        /// A method used to verify whether the attachment have been deleted or not.
        /// </summary>
        /// <param name="fullUrlOfAttachment">A parameter represents the full url of attachment which is used by HTTPGET operation to get the actual attachment content.</param>
        /// <returns>Return true indicating delete attachment succeed.</returns>
        private bool VerifyDeleteAttachmentSucceed(string fullUrlOfAttachment)
        {
            if (string.IsNullOrEmpty(fullUrlOfAttachment))
            {
                throw new ArgumentNullException("fullUrlOfAttachment");
            }

            HttpStatusCode lowLevelStatusCode = HttpStatusCode.OK;
            Uri            fullUrlOfAttachmentPath;

            if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath))
            {
                this.Site.Assert.Fail("The full url of attachment should be valid Uri format string.");
            }

            try
            {
                OutspsAdapter.HTTPGET(fullUrlOfAttachmentPath, "f");
            }
            catch (WebException webException)
            {
                lowLevelStatusCode = this.GetStatusCodeFromWebException(webException);
                Site.Log.Add(LogEntryKind.Debug, "The attachment has not been found" + webException.Message.ToString());
            }

            this.Site.Assert.AreEqual <HttpStatusCode>(
                HttpStatusCode.NotFound,
                lowLevelStatusCode,
                @"The protocol SUT should return ""404"" status code which means ""NotFound"", if the attachment[{0}] have been deleted.",
                fullUrlOfAttachment);
            return(true);
        }
示例#2
0
        /// <summary>
        /// A method used to verify attachment contents' length which is got from protocol SUT whether equal to specified value. If it does not pass the verification, this method will throw a Assert exception.
        /// </summary>
        /// <param name="fullUrlOfAttachment">A parameter represents the full url of attachment which is used by HTTPGET operation to get the actual attachment content.</param>
        /// <param name="expectedContentsLength">A parameter represents the expected content length.</param>
        /// <returns>Return true indicating the attachment content length equal to the expected value.</returns>
        private bool VerifyAttachmentContentsLength(string fullUrlOfAttachment, int expectedContentsLength)
        {
            if (string.IsNullOrEmpty(fullUrlOfAttachment))
            {
                throw new ArgumentNullException("fullUrlOfAttachment");
            }

            Uri fullUrlOfAttachmentPath;

            if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath))
            {
                this.Site.Assert.Fail("The full url of attachment should be valid Uri format string.");
            }

            byte[] getContentsOfAttachment = OutspsAdapter.HTTPGET(fullUrlOfAttachmentPath, "f");

            this.Site.Assert.AreEqual <int>(
                expectedContentsLength,
                getContentsOfAttachment.Length,
                "The attachment contents' length should equal to expected value[{0}]",
                expectedContentsLength);
            return(true);
        }
示例#3
0
        public void MSOUTSPS_S01_TC04_OperateAttachment_TasksTemplateType()
        {
            #region Add a list item

            // Add one list into SUT.
            string listId = this.AddListToSUT(TemplateType.Tasks);

            // Add one list item
            List <string> addedListitems    = this.AddItemsToList(listId, 1);
            string        addedListitemId   = addedListitems[0];
            byte[]        attachmentContent = this.GenerateUniqueAttachmentContents(5);
            string        attachmentName    = this.GetUniqueAttachmentName();

            #endregion

            #region AddAttachment operation

            // Call AddAttachment operation.
            OutspsAdapter.AddAttachment(
                listId,
                addedListitemId,
                attachmentName,
                attachmentContent);

            #endregion

            #region HTTPGET operation

            // Get full URL of an attachment
            string fullUrlOfAttachment = this.GetAttachmentFullUrl(listId, addedListitemId, attachmentName);

            // Call HTTPGET operation.
            Uri fullUrlOfAttachmentPath;
            if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath))
            {
                this.Site.Assert.Fail("The full url of attachment should be valid Uri format string.");
            }

            byte[] getContentsOfAttachment = OutspsAdapter.HTTPGET(fullUrlOfAttachmentPath, "f");

            this.Site.Assert.AreEqual <int>(
                attachmentContent.Length,
                getContentsOfAttachment.Length,
                "The attachment content's length should equal to added by AddAttachment operation.");

            #endregion

            #region GetAttachmentCollection operation

            byte[] attachmentContentSecond = this.GenerateUniqueAttachmentContents(5);
            string attachmentNameSecond    = this.GetUniqueAttachmentName();

            // Call the AddAttachment operation.
            OutspsAdapter.AddAttachment(
                listId,
                addedListitemId,
                attachmentNameSecond,
                attachmentContentSecond);

            // Call GetAttachmentCollection operation.
            GetAttachmentCollectionResponseGetAttachmentCollectionResult getAttachementCollectionResult = OutspsAdapter.GetAttachmentCollection(listId, addedListitemId);

            // If add new attachment successfully, total attachment number is 2
            this.VerifyWhetherContainExpectedNumberAttachment(getAttachementCollectionResult, 2);

            #endregion

            if (Common.IsRequirementEnabled(106802, this.Site))
            {
                #region GetListItemChangesSinceToken operation

                // Set CamlQueryOptions and view fields make the "attachment" field present in response.
                CamlQueryOptions camloptions = new CamlQueryOptions();
                camloptions.QueryOptions = new CamlQueryOptionsQueryOptions();
                camloptions.QueryOptions.IncludeAttachmentUrls    = bool.TrueString;
                camloptions.QueryOptions.IncludeAttachmentVersion = bool.TrueString;
                CamlViewFields viewfieds = this.GenerateViewFields(false, new List <string> {
                    "Attachments"
                });

                // Call GetListItemChangesSinceToken operation.
                GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult getlistItemChangesRes = null;
                getlistItemChangesRes = OutspsAdapter.GetListItemChangesSinceToken(
                    listId,
                    null,
                    null,
                    viewfieds,
                    null,
                    camloptions,
                    null,
                    null);

                this.Site.Assert.IsNotNull(getlistItemChangesRes, "SUT should return a response contain data.");
                string headerValue = this.GetIfMatchHeaderValueFromResponse(getlistItemChangesRes, fullUrlOfAttachment, int.Parse(addedListitemId));

                #endregion

                #region HTTPPUT operation

                // Call HTTPPUT operation.
                fullUrlOfAttachmentPath = null;
                if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath))
                {
                    this.Site.Assert.Fail("The full url of attachment should be valid Uri format string.");
                }

                byte[] newattachmentContents = this.GenerateUniqueAttachmentContents(6);
                OutspsAdapter.HTTPPUT(fullUrlOfAttachmentPath, headerValue, newattachmentContents);

                // Verify updated attachment.
                this.VerifyAttachmentContentsLength(fullUrlOfAttachment, newattachmentContents.Length);
                #endregion
            }

            OutspsAdapter.DeleteAttachment(listId, addedListitemId, fullUrlOfAttachment);

            // Verify whether delete attachment succeed.
            this.VerifyDeleteAttachmentSucceed(fullUrlOfAttachment);
        }
示例#4
0
        public void MSOUTSPS_S01_TC01_OperateAttachment_AppointmentTemplateType()
        {
            #region Add a list item

            // Add one list into SUT.
            string listId = this.AddListToSUT(TemplateType.Events);

            // Add one list item
            List <string> addedListitems    = this.AddItemsToList(listId, 1);
            string        addedListitemId   = addedListitems[0];
            byte[]        attachmentContent = this.GenerateUniqueAttachmentContents(5);
            string        attachmentName    = this.GetUniqueAttachmentName();

            #endregion

            #region AddAttachment operation

            // Call AddAttachment operation.
            string fileUrl = OutspsAdapter.AddAttachment(
                listId,
                addedListitemId,
                attachmentName,
                attachmentContent);

            #endregion

            #region HTTPGET operation

            // Get full URL of an attachment
            string fullUrlOfAttachment = this.GetAttachmentFullUrl(listId, addedListitemId, attachmentName);
            Uri    fullUrlOfAttachmentPath;
            if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath))
            {
                this.Site.Assert.Fail("The full url of attachment should be valid Uri format string.");
            }

            // Call HTTPGET operation.
            byte[] getContentsOfAttachment = OutspsAdapter.HTTPGET(fullUrlOfAttachmentPath, "f");

            #endregion

            #region Capture R1062, R1070, R1073, R1075

            // If the length of attachment content in protocol SUT equal to added by AddAttachment operation, then capture R1062, R1070, R1073
            Site.CaptureRequirementIfAreEqual(
                attachmentContent.Length,
                getContentsOfAttachment.Length,
                1062,
                "[In Message Processing Events and Sequencing Rules][The operation]AddAttachment Adds an attachment to an item.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R1070
            Site.CaptureRequirementIfAreEqual(
                attachmentContent.Length,
                getContentsOfAttachment.Length,
                1070,
                "[In AddAttachment]AddAttachment is used by protocol clients to create a new attachment on an item on the protocol server.");

            // Verify MS-OUTSPS requirement: MS-OUTSPS_R10730
            Site.CaptureRequirementIfAreEqual(
                attachmentContent.Length,
                getContentsOfAttachment.Length,
                10730,
                "[In Messages]AddAttachmentResponse specified the response to a request to create a new attachment on an item on the protocol server.");

            // If the AddAttachment operation return valid attachment url, then Capture R1075
            Site.CaptureRequirementIfIsNotNull(
                fileUrl,
                1075,
                "[In AddAttachmentResponse]If an AddAttachmentResponse is received, then the upload was successful.");

            #endregion

            #region GetAttachmentCollection operation

            byte[] attachmentContentSecond = this.GenerateUniqueAttachmentContents(5);
            string attachmentNameSecond    = this.GetUniqueAttachmentName();

            // Call the AddAttachment operation.
            OutspsAdapter.AddAttachment(
                listId,
                addedListitemId,
                attachmentNameSecond,
                attachmentContentSecond);

            // Call GetAttachmentCollection operation.
            GetAttachmentCollectionResponseGetAttachmentCollectionResult getAttachementCollectionResult = OutspsAdapter.GetAttachmentCollection(listId, addedListitemId);

            #endregion

            #region Capture R1065, R11000

            // If add new attachment successfully, total attachment number is 2, Capture R1065, R11000
            bool isContainExpectedAttachment = this.VerifyWhetherContainExpectedNumberAttachment(getAttachementCollectionResult, 2);

            this.Site.CaptureRequirementIfIsTrue(
                isContainExpectedAttachment,
                1065,
                "[In Message Processing Events and Sequencing Rules][The operation]GetAttachmentCollection Gets a list of the attachments on an item.");

            this.Site.CaptureRequirementIfIsTrue(
                isContainExpectedAttachment,
                11000,
                "[In Messages]GetAttachmentCollectionResponse specified the response to a request to get the list of all attachments on a single item in one list.");

            #endregion

            if (Common.IsRequirementEnabled(106802, this.Site))
            {
                #region GetListItemChangesSinceToken operation

                // Set CamlQueryOptions and view fields make the "attachment" field present in response.
                CamlQueryOptions camloptions = new CamlQueryOptions();
                camloptions.QueryOptions = new CamlQueryOptionsQueryOptions();
                camloptions.QueryOptions.IncludeAttachmentUrls    = bool.TrueString;
                camloptions.QueryOptions.IncludeAttachmentVersion = bool.TrueString;
                CamlViewFields viewfieds = this.GenerateViewFields(false, new List <string> {
                    "Attachments"
                });

                // Call GetListItemChangesSinceToken operation.
                GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult getListItemChangesRes = null;
                getListItemChangesRes = OutspsAdapter.GetListItemChangesSinceToken(
                    listId,
                    null,
                    null,
                    viewfieds,
                    null,
                    camloptions,
                    null,
                    null);

                this.Site.Assert.IsNotNull(getListItemChangesRes, "SUT should return a response contain data.");
                string headerValue = this.GetIfMatchHeaderValueFromResponse(getListItemChangesRes, fullUrlOfAttachment, int.Parse(addedListitemId));

                #endregion

                #region Capture R1241

                // If the header is returned, then R1241 should be covered.
                this.Site.CaptureRequirementIfIsNotNull(
                    headerValue,
                    1241,
                    "[In HTTP PUT]The Attachments property MUST contain a file version if protocol clients have included the IncludeAttachmentUrls and IncludeAttachmentVersion elements specified in [MS-LISTSWS].");

                #endregion

                #region HTTPPUT operation

                // Call HTTPPUT operation to update the attachment contents for the first attachment.
                fullUrlOfAttachmentPath = null;
                if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath))
                {
                    this.Site.Assert.Fail("The full url of attachment should be valid Uri format string.");
                }

                byte[] newattachmentContents = this.GenerateUniqueAttachmentContents(6);
                OutspsAdapter.HTTPPUT(fullUrlOfAttachmentPath, headerValue, newattachmentContents);

                // Verify the updated attachment contents' length
                this.VerifyAttachmentContentsLength(fullUrlOfAttachment, newattachmentContents.Length);

                #endregion
            }

            OutspsAdapter.DeleteAttachment(listId, addedListitemId, fullUrlOfAttachment);

            #region Capture R10930

            // If the operation does not return SoapException, capture R10930 directly. Because the schema of the DeleteAttachmentResponse define in [MS-LISTSWS]: <s:element name="DeleteAttachmentResponse"><s:complexType/></s:element>, does not contain any complex type definition, so the proxy class marked this operation as void type return.
            this.Site.CaptureRequirement(
                10930,
                "[In Messages]DeleteAttachmentResponse specified the response to a request to delete attachments from an item on the protocol server.");

            #endregion

            // Verify whether the attachment was deleted.
            bool isDeleteSucceed = this.VerifyDeleteAttachmentSucceed(fullUrlOfAttachment);

            #region Capture R1064, R1091

            // Because the specified attachment was deleted, the HTTPGET operation could not find it, so there will have a soap exception.
            this.Site.CaptureRequirementIfIsTrue(
                isDeleteSucceed,
                1064,
                @"[In Message Processing Events and Sequencing Rules][The operation]DeleteAttachment Deletes an attachment from an item on a list.");

            this.Site.CaptureRequirementIfIsTrue(
                isDeleteSucceed,
                1091,
                @"[In DeleteAttachment]Protocol clients use DeleteAttachment to delete attachments from an item on the protocol server.");

            #endregion
        }