예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// The GetListItemChanges operation is used to retrieve the list items that have been inserted or updated
        /// since the specified date and time and matching the specified filter criteria.
        /// </summary>
        /// <param name="listName">The name of the list from which the list item changes will be got</param>
        /// <param name="viewFields">Indicates which fields of the list item SHOULD be returned</param>
        /// <param name="since">The date and time to start retrieving changes in the list
        /// If the parameter is null, protocol server should return all list items
        /// If the date that is passed in is not in UTC format, protocol server will use protocol server's local time zone and convert it to UTC time</param>
        /// <param name="contains">Restricts the results returned by giving a specific value to be searched for in the specified list item field</param>
        /// <returns>Return the list item change result</returns>
        public GetListItemChangesResponseGetListItemChangesResult GetListItemChanges(string listName, CamlViewFields viewFields, string since, CamlContains contains)
        {
            if (null == this.listsProxy)
            {
                throw new InvalidOperationException("The Proxy instance is NULL, need to initialize the adapter");
            }

            GetListItemChangesResponseGetListItemChangesResult result = null;

            result = this.listsProxy.GetListItemChanges(listName, viewFields, since, contains);
            this.VerifyTransportRequirement();

            return(result);
        }
예제 #3
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
        }
예제 #4
0
        /// <summary>
        /// The GetListItemChangesSinceToken operation is used to return changes made to a specified list after the event
        /// expressed by the change token, if specified, or to return all the list items in the list.
        /// </summary>
        /// <param name="listName">The name of the list from which version collection will be got</param>
        /// <param name="viewName">The GUID refers to a view of the list</param>
        /// <param name="query">The query to determine which records from the list are to be
        /// returned and the order in which they will be returned</param>
        /// <param name="viewFields">Specifies which fields of the list item will be returned</param>
        /// <param name="rowLimit">Indicate the maximum number of rows of data to return</param>
        /// <param name="queryOptions">Specifies various options for modifying the query</param>
        /// <param name="changeToken">Assigned a string comprising a token returned by a previous
        /// call to this operation.</param>
        /// <param name="contains">Specifies a value to search for</param>
        /// <returns>A return value represent the list item changes since the specified token</returns>
        public GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult GetListItemChangesSinceToken(string listName, string viewName, GetListItemChangesSinceTokenQuery query, CamlViewFields viewFields, string rowLimit, CamlQueryOptions queryOptions, string changeToken, CamlContains contains)
        {
            if (null == this.listsProxy)
            {
                throw new InvalidOperationException("The Proxy instance is NULL, need to initialize the adapter");
            }

            GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult result = null;

            result = this.listsProxy.GetListItemChangesSinceToken(listName, viewName, query, viewFields, rowLimit, queryOptions, changeToken, contains);
            this.VerifyTransportRequirement();
            this.VerifyGetListItemChangesSinceTokenResponse(result);

            return(result);
        }