internal Properties FetchCalendarItem(string itemId, string folderId)
        {
            ItemOperationsRequest  itemOperationsRequest  = EasRequestGenerator.CreateItemOpsRequestForCalendarItem(itemId, folderId);
            ItemOperationsResponse itemOperationsResponse = this.ItemOperations(itemOperationsRequest);

            return(itemOperationsResponse.GetCalendarItemProperties());
        }
예제 #2
0
        public void MSASAIRS_S03_TC01_FileReference_ZeroLengthString()
        {
            #region Send a mail with normal attachment.
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.NormalAttachment, subject, body);
            #endregion

            #region Send an ItemOperations request with the value of FileReference element as a zero-length string.
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);

            // Send an ItemOperations request with the value of FileReference element as a zero-length string.
            ItemOperationsRequest request = TestSuiteHelper.CreateItemOperationsRequest(this.User2Information.InboxCollectionId, syncItem.ServerId, string.Empty, null, null);

            DataStructures.ItemOperationsStore itemOperationsStore = this.ASAIRSAdapter.ItemOperations(request, DeliveryMethodForFetch.Inline);

            Site.Assert.AreEqual <int>(
                1,
                itemOperationsStore.Items.Count,
                "There should be 1 item in ItemOperations response.");
            #endregion

            #region Verify requirements
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R214");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R214
            Site.CaptureRequirementIfAreEqual <string>(
                "15",
                itemOperationsStore.Items[0].Status,
                214,
                @"[In FileReference (Fetch)] If the client includes a zero-length string for the value of this element [the FileReference (Fetch) element] in an ItemOperations command request, the server responds with a protocol status error of 15.");
            #endregion
        }
예제 #3
0
        public void MSASCON_S03_TC03_ItemOperations_Status2()
        {
            #region Create a conversation and get the created conversation item
            string           conversationSubject = Common.GenerateResourceName(Site, "Conversation");
            ConversationItem conversationItem    = this.CreateConversation(conversationSubject);
            #endregion

            #region Call ItemOperations command with invalid MoveAlways element.
            // Create an ItemOperations request and set invalid content to the MoveAlways element.
            ItemOperationsMove move = new ItemOperationsMove
            {
                DstFldId       = User1Information.DeletedItemsCollectionId,
                ConversationId = conversationItem.ConversationId,
                Options        = new ItemOperationsMoveOptions {
                    MoveAlways = "MoveAlwaysContent"
                }
            };

            ItemOperationsRequest  itemOperationRequest  = Common.CreateItemOperationsRequest(new object[] { move });
            ItemOperationsResponse itemOperationResponse = this.CONAdapter.ItemOperations(itemOperationRequest);
            Site.Assert.AreEqual("1", itemOperationResponse.ResponseData.Status, "The ItemOperations operation should be success.");
            Site.Assert.AreEqual(1, itemOperationResponse.ResponseData.Response.Move.Length, "The server should return a Move element in ItemOperationsResponse.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R144");

            // Verify MS-ASCON requirement: MS-ASCON_R144
            Site.CaptureRequirementIfAreEqual(
                "2",
                itemOperationResponse.ResponseData.Response.Move[0].Status,
                144,
                @"[In Status] [The meaning of status value] 2  [is] Protocol error. The XML is not valid.");
            #endregion
        }
예제 #4
0
        /// <summary>
        /// Fetch item with specified ServerID on the server.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The server id of the mail.</param>
        /// <param name="fileReference">The file reference of the attachment.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <param name="deliveryMethod">Indicate whether use multipart or inline method to send the request.</param>
        /// <returns>The item with specified ServerID.</returns>
        protected DataStructures.ItemOperations GetItemOperationsResult(string collectionId, string serverId, string fileReference, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences, DeliveryMethodForFetch?deliveryMethod)
        {
            DataStructures.ItemOperations item    = null;
            ItemOperationsRequest         request = TestSuiteHelper.CreateItemOperationsRequest(collectionId, serverId, fileReference, bodyPreferences, bodyPartPreferences);

            int counter    = 0;
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            do
            {
                Thread.Sleep(waitTime);
                DataStructures.ItemOperationsStore itemOperationsStore = this.ASAIRSAdapter.ItemOperations(request, deliveryMethod ?? DeliveryMethodForFetch.Inline);

                // Since the item serverId or attachment fileReference is unique, there should be only one item in response
                this.Site.Assert.AreEqual <int>(
                    1,
                    itemOperationsStore.Items.Count,
                    "The count of Items in ItemOperations command response should be 1.");

                if (itemOperationsStore.Items[0].Email != null)
                {
                    item = itemOperationsStore.Items[0];
                }
            }while (item == null && counter < retryCount);

            this.Site.Assert.IsNotNull(item, "The item should be found, retry count: {0}.", counter);

            return(item);
        }
예제 #5
0
        public void MSASCON_S03_TC07_ItemOperations_Status164()
        {
            this.CheckActiveSyncVersionIsNot140();

            #region User2 sends an email to User1
            this.SwitchUser(this.User2Information, true);

            string subject             = Common.GenerateResourceName(Site, "Subject");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);

            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, null);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            #region Call ItemOperations command with BodyPartPreference element and set the Type element to 3
            this.SwitchUser(this.User1Information, false);

            DataStructures.Sync syncItem           = this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, null);
            BodyPartPreference  bodyPartPreference = new BodyPartPreference()
            {
                Type = 3,
            };

            ItemOperationsRequest  itemOperationsRequest  = TestSuiteHelper.GetItemOperationsRequest(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, null);
            ItemOperationsResponse itemOperationsResponse = this.CONAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual("1", itemOperationsResponse.ResponseData.Status, "The ItemOperations operation should be success.");
            this.VerifyMessagePartStatus164(byte.Parse(itemOperationsResponse.ResponseData.Response.Fetch[0].Status));
            #endregion
        }
 /// <summary>
 /// Retrieves data from the server for one or more individual documents.
 /// </summary>
 /// <param name="itemOperationsRequest">ItemOperations command request.</param>
 /// <param name="deliverMethod">Deliver method parameter.</param>
 /// <returns>ItemOperations command response.</returns>
 public ItemOperationsResponse ItemOperations(ItemOperationsRequest itemOperationsRequest, DeliveryMethodForFetch deliverMethod)
 {
     ItemOperationsResponse itemOperationsResponse = this.activeSyncClient.ItemOperations(itemOperationsRequest, deliverMethod);
     Site.Assert.AreEqual<HttpStatusCode>(HttpStatusCode.OK, itemOperationsResponse.StatusCode, "The call should be successful.");
     this.VerifyTransport();
     this.VerifyItemOperations(itemOperationsResponse);
     this.VerifyWBXMLCapture();
     return itemOperationsResponse;
 }
예제 #7
0
        public void MSASDOC_S02_TC03_ItemOperations_WithMultipart()
        {
            #region Client calls ItemOperations command to get data of a shared visible document.

            // Build element Fetch.
            ItemOperationsFetch fetch = this.FetchElementBuilder(Common.GetConfigurationPropertyValue("SharedVisibleDocument", Site));

            // Create an ItemOperation command request.
            ItemOperationsRequest itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetch });

            // Send request and get response.
            ItemOperationsResponse itemOperationResponse = this.ASDOCAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.MultiPart);
            Site.Assert.AreEqual <int>(1, itemOperationResponse.ResponseData.Response.Fetch.Length, "Only one document's information should be returned.");
            Site.Assert.AreEqual <string>("1", itemOperationResponse.ResponseData.Response.Fetch[0].Status, "The call should be successful.");

            #endregion

            // Multipart responses have a Content-Type header with the value "application/vnd.ms-sync.multipart".
            bool isMultiPartResponse = itemOperationResponse.Headers.ToString().Contains("application/vnd.ms-sync.multipart");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R124, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R124
            // If header contains "application/vnd.ms-sync.multipart" the body is encoded as binary data.
            Site.CaptureRequirementIfIsTrue(
                isMultiPartResponse,
                124,
                @"[In Requesting the Document Body from the Server] The body of the document is returned as [either text encoded with base64 encoding in the itemoperations:Data element ([MS-ASCMD] section 2.2.3.39.1) of the ItemOperations command response or as] binary data, depending on the content type that the client requested.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R76, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R76
            Site.CaptureRequirementIfIsTrue(
                isMultiPartResponse,
                76,
                @"[In ItemOperations Command Request] A client can use the HTTP header (2) MS-ASAcceptMultiPart: T to specify that the server returns the document data in multipart binary format.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R120, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R120
            Site.CaptureRequirementIfIsTrue(
                isMultiPartResponse,
                120,
                @"[In Retrieving the Document Body] The server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8), which returns the body of the document as binary text in multiple parts if the command request was a multi-part request.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R106, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R106
            Site.CaptureRequirementIfIsTrue(
                isMultiPartResponse,
                106,
                @"[In ItemOperations Command Response] If an ItemOperations command request for the body of the document was made using the MS-ASAcceptMultiPart: T header (2), then the server MUST respond by providing the document body as binary data in multiple parts.");
        }
        /// <summary>
        /// Acts as a container for the Fetch element, the EmptyFolderContents element, and the Move element to provide batched online handling of these operations against the server.
        /// </summary>
        /// <param name="request">An ItemOperationsRequest object that contains the request information.</param>
        /// <param name="deliveryMethod">Delivery method specifies what kind of response is accepted.</param>
        /// <returns>ItemOperations command response</returns>
        public ItemOperationsResponse ItemOperations(ItemOperationsRequest request, DeliveryMethodForFetch deliveryMethod)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(request, deliveryMethod);

            this.VerifyTransportRequirements();
            this.VerifyWBXMLCapture(CommandName.ItemOperations, response);
            this.VerifyItemOperationsCommand(response);
            return(response);
        }
        public void MSASNOTE_S03_TC02_ItemOperations_SchemaViewFetch()
        {
            #region Call method Sync to add a note to the server
            Dictionary <Request.ItemsChoiceType8, object> addElements = this.CreateNoteElements();
            this.SyncAdd(addElements, 1);
            #endregion

            #region Call method Search to search notes using the given keyword text

            // Search note from server
            SearchStore result = this.NOTEAdapter.Search(this.UserInformation.NotesCollectionId, addElements[Request.ItemsChoiceType8.Subject1].ToString(), true, 1);

            Site.Assert.AreEqual <int>(
                1,
                result.Results.Count,
                @"There should be only one note item returned in sync response.");

            #endregion

            #region Call method ItemOperations to fetch all the information about notes using longIds.
            // longIds:Long id of the created note item.
            List <string> longIds = new List <string> {
                result.Results[0].LongId
            };

            Request.BodyPreference bodyReference = new Request.BodyPreference {
                Type = 1
            };
            Request.Schema schema = new Request.Schema
            {
                ItemsElementName = new Request.ItemsChoiceType4[1],
                Items            = new object[] { new Request.Body() }
            };
            schema.ItemsElementName[0] = Request.ItemsChoiceType4.Body;

            // serverIds:null
            ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(null, null, longIds, bodyReference, schema);
            ItemOperationsStore   itemOperationsResult = this.NOTEAdapter.ItemOperations(itemOperationRequest);
            Site.Assert.IsNotNull(itemOperationsResult, "The ItemOperations result must not be null!");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASNOTE_R103");

            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.Subject, "Subject should be null.");
            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.MessageClass, "MessageClass should be null.");
            Site.Assert.IsNull(itemOperationsResult.Items[0].Note.Categories, "Categories should be null.");
            Site.Assert.IsFalse(itemOperationsResult.Items[0].Note.IsLastModifiedDateSpecified, "LastModifiedSpecified should not be present.");

            // Verify MS-ASNOTE requirement: MS-ASNOTE_R103
            Site.CaptureRequirementIfIsNotNull(
                itemOperationsResult.Items[0].Note.Body,
                103,
                @"[In ItemOperations Command Response] If an itemoperations:Schema element ([MS-ASCMD] section 2.2.3.145) is included in the ItemOperations command request, then the elements returned in the ItemOperations command response MUST be restricted to the elements that were included as child elements of the ItemOperations:Schema element in the command request.");

            #endregion
        }
예제 #10
0
        public void MSASDOC_S02_TC02_ItemOperations_GetZeroOrMoreDocumentClass()
        {
            #region Client calls ItemOperations command to get data of a nonexistent document under a shared folder.

            // Build element Fetch.
            ItemOperationsFetch fetchZeroDoc = this.FetchElementBuilder(Common.GetConfigurationPropertyValue("SharedVisibleDocument", Site) + Guid.NewGuid().ToString());

            // Create an ItemOperation command request that zero document class value will be returned.
            ItemOperationsRequest itemOperationsGetZeroDocRequest = Common.CreateItemOperationsRequest(new object[] { fetchZeroDoc });

            // Send request and get response.
            ItemOperationsResponse itemOperationGetZeroDocResponse = this.ASDOCAdapter.ItemOperations(itemOperationsGetZeroDocRequest, DeliveryMethodForFetch.Inline);

            // Make sure this file doesn't exist.
            Site.Assert.AreEqual <int>(1, itemOperationGetZeroDocResponse.ResponseData.Response.Fetch.Length, "Only one fetch element should be returned.");
            Site.Assert.AreEqual <string>("6", itemOperationGetZeroDocResponse.ResponseData.Response.Fetch[0].Status, "Document information should not be returned.");

            #endregion

            #region Client calls ItemOperations command to get data of a shared visible document and a shared hidden document.

            // Build element Fetch.
            ItemOperationsFetch fetch1 = this.FetchElementBuilder(Common.GetConfigurationPropertyValue("SharedHiddenDocument", Site));
            ItemOperationsFetch fetch2 = this.FetchElementBuilder(Common.GetConfigurationPropertyValue("SharedVisibleDocument", Site));

            ItemOperationsFetch[] fetches = new ItemOperationsFetch[] { fetch1, fetch2 };

            // Create an ItemOperation command request that multiple document class value will be returned.
            ItemOperationsRequest itemOperationGetMoreDocRequest = Common.CreateItemOperationsRequest(fetches);

            // Send request and get response.
            ItemOperationsResponse itemOperationGetMoreDocResponse = this.ASDOCAdapter.ItemOperations(itemOperationGetMoreDocRequest, DeliveryMethodForFetch.Inline);

            // Information of the two documents is returned.
            Site.Assert.AreEqual <int>(2, itemOperationGetMoreDocResponse.ResponseData.Response.Fetch.Length, "Two document class items should be returned.");
            Site.Assert.AreEqual <string>("1", itemOperationGetMoreDocResponse.ResponseData.Response.Fetch[0].Status, "Document information should be returned.");
            Site.Assert.AreEqual <string>("1", itemOperationGetMoreDocResponse.ResponseData.Response.Fetch[1].Status, "Document information should be returned");

            #endregion

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R102");

            // Items that match the criteria are returned.
            Site.CaptureRequirement(
                102,
                @"[In ItemOperations Command Response] The server MUST return a Document class XML block for every item that matches the criteria specified in the client command request.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R103");

            // Server can return zero or more documents class blocks which can be seen from two steps above.
            Site.CaptureRequirement(
                103,
                @"[In ItemOperations Command Response] The server can return zero or more Document class blocks in its response, depending on how many document items match the criteria specified in the client command request.");
        }
예제 #11
0
        /// <summary>
        /// Retrieves data from the server for one or more individual documents.
        /// </summary>
        /// <param name="itemOperationsRequest">ItemOperations command request.</param>
        /// <param name="deliverMethod">Deliver method parameter.</param>
        /// <returns>ItemOperations command response.</returns>
        public ItemOperationsResponse ItemOperations(ItemOperationsRequest itemOperationsRequest, DeliveryMethodForFetch deliverMethod)
        {
            ItemOperationsResponse itemOperationsResponse = this.activeSyncClient.ItemOperations(itemOperationsRequest, deliverMethod);

            Site.Assert.AreEqual <HttpStatusCode>(HttpStatusCode.OK, itemOperationsResponse.StatusCode, "The call should be successful.");
            this.VerifyTransport();
            this.VerifyItemOperations(itemOperationsResponse);
            this.VerifyWBXMLCapture();
            return(itemOperationsResponse);
        }
예제 #12
0
        /// <summary>
        /// Fetch all the information about calendars using longIds or ServerIds
        /// </summary>
        /// <param name="itemOperationsRequest">The request for ItemOperations</param>
        /// <returns>The fetch items information</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            ItemOperationsStore    itemOperationResponse = Common.LoadItemOperationsResponse(response);

            Site.Assert.IsNotNull(itemOperationResponse, "ItemOperation command response should be returned successfully.");
            this.VerifyTransport();
            this.VerifyItemOperationsResponse(itemOperationResponse);

            return(itemOperationResponse);
        }
        /// <summary>
        /// Retrieves an item from the server by sending ItemOperationsRequest object.
        /// </summary>
        /// <param name="request">An ItemOperationsRequest object which contains the request information.</param>
        /// <param name="deliveryMethod">The delivery method specifies what kind of response is accepted.</param>
        /// <returns>An ItemOperationsStore object.</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest request, DeliveryMethodForFetch deliveryMethod)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(request, deliveryMethod);
            Site.Assert.IsNotNull(response, "If the ItemOperations command executes successfully, the response from server should not be null.");
            ItemOperationsStore itemOperationsStore = Common.LoadItemOperationsResponse(response);
            this.VerifyTransport();
            this.VerifyWBXMLCapture();
            this.VerifyItemOperationsResponse(itemOperationsStore);

            return itemOperationsStore;
        }
예제 #14
0
        /// <summary>
        /// Delete all items from the specified collection
        /// </summary>
        /// <param name="collectionId">The specified collection id</param>
        public void DeleteAllItems(string collectionId)
        {
            ItemOperationsRequest itemOperationsRequest       = TestSuiteHelper.CreateItemOperationsEmptyFolderContentsRequest(collectionId);
            ItemOperationsStore   emptyFolderContentsResponse = this.CALAdapter.ItemOperations(itemOperationsRequest);

            // Verify itemOperations response, if the command executes successfully, the Status in response should be 1.
            Site.Assert.AreEqual <string>(
                "1",
                emptyFolderContentsResponse.Status,
                "If the command executes successfully, the Status in response should be 1.");
        }
예제 #15
0
        internal static ItemOperationsRequest CreateItemOpsRequestForCalendarItem(string messageId, string folderId)
        {
            ItemOperationsRequest itemOperationsRequest = EasRequestGenerator.CreateItemOpsRequest(messageId, folderId);

            itemOperationsRequest.Fetches[0].Options.BodyPreference = new BodyPreference
            {
                Type           = new byte?(1),
                AllOrNone      = new bool?(true),
                TruncationSize = new uint?(10000U)
            };
            return(itemOperationsRequest);
        }
        /// <summary>
        /// Fetch all information about exchange object.
        /// </summary>
        /// <param name="itemOperationsRequest">The request for itemOperations.</param>
        /// <returns>The ItemOperations result which is returned from server.</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null.");
            ItemOperationsStore result = Common.LoadItemOperationsResponse(response);

            this.VerifyTransport();
            this.VerifyItemOperations(result);
            this.VerifyWBXMLCapture();
            return(result);
        }
예제 #17
0
        /// <summary>
        /// Acts as a container for the Fetch element, the EmptyFolderContents element, and the Move element to provide batched online handling of these operations against the server.
        /// </summary>
        /// <param name="itemOperationsRequest">An ItemOperationsRequest object that contains the request information.</param>
        /// <returns>ItemOperations command response.</returns>
        public ItemOperationsResponse ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse itemOperationsResponse = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            Site.Assert.IsNotNull(itemOperationsResponse, "The ItemOperations response returned from server should not be null.");

            // Verify related requirements.
            this.VerifyCommonRequirements();
            this.VerifyWBXMLCapture();
            this.VerifyItemOperationsCommandResponse(itemOperationsResponse);

            return(itemOperationsResponse);
        }
예제 #18
0
        /// <summary>
        /// Fetch all information about exchange object
        /// </summary>
        /// <param name="itemOperationsRequest">ItemOperations command request.</param>
        /// <returns>The ItemOperations result which is returned from server</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            this.VerifyItemOperationsResponse(response);
            ItemOperationsStore result = Common.LoadItemOperationsResponse(response);
            bool hasSchemaElement      = AdapterHelper.ContainsSchemaElement(itemOperationsRequest);

            this.VerifyTransport();
            this.VerifyItemOperationResult(result, hasSchemaElement);
            this.VerifyWBXMLCapture();
            return(result);
        }
예제 #19
0
        internal Properties FetchMessageItem(string messageId, string folderId)
        {
            ItemOperationsRequest  itemOperationsRequest = EasRequestGenerator.CreateItemOpsRequest(messageId, folderId);
            ItemOperationsResponse response = this.ItemOperations(itemOperationsRequest);
            ItemOperationsStatus   status;
            Properties             messageProperties = response.GetMessageProperties(0, out status);

            EasConnectionWrapper.WrapException(delegate()
            {
                response.ThrowIfStatusIsFailed(status);
            }, (ConnectionsTransientException e) => new EasFetchFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasFetchFailedPermanentException(e.Message, e));
            return(messageProperties);
        }
        /// <summary>
        /// Retrieves an item from the server by sending ItemOperationsRequest object.
        /// </summary>
        /// <param name="request">An ItemOperationsRequest object which contains the request information.</param>
        /// <param name="deliveryMethod">The delivery method specifies what kind of response is accepted.</param>
        /// <returns>An ItemOperationsStore object.</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest request, DeliveryMethodForFetch deliveryMethod)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(request, deliveryMethod);

            Site.Assert.IsNotNull(response, "If the ItemOperations command executes successfully, the response from server should not be null.");
            ItemOperationsStore itemOperationsStore = Common.LoadItemOperationsResponse(response);

            this.VerifyTransport();
            this.VerifyWBXMLCapture();
            this.VerifyItemOperationsResponse(itemOperationsStore);

            return(itemOperationsStore);
        }
예제 #21
0
        /// <summary>
        /// Create an ItemOperations command request.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The serverId of the item.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <param name="schema">Sets the schema information.</param>
        /// <returns>An ItemOperations command request.</returns>
        internal static ItemOperationsRequest CreateItemOperationsRequest(string collectionId, string serverId, Request.BodyPreference bodyPreference, Request.Schema schema)
        {
            ItemOperationsRequest request = new ItemOperationsRequest {
                RequestData = new Request.ItemOperations()
            };

            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                Store        = SearchName.Mailbox.ToString(),
                CollectionId = collectionId,
                ServerId     = serverId
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType5> itemsElementName = new List <Request.ItemsChoiceType5>();

            if (null != schema)
            {
                itemsElementName.Add(Request.ItemsChoiceType5.Schema);
                items.Add(schema);
            }

            if (null != bodyPreference)
            {
                itemsElementName.Add(Request.ItemsChoiceType5.BodyPreference);
                items.Add(bodyPreference);

                if (bodyPreference.Type == 0x4)
                {
                    itemsElementName.Add(Request.ItemsChoiceType5.MIMESupport);

                    // '2' indicates server sends MIME data for all messages but not S/MIME messages only
                    items.Add((byte)0x2);
                }
            }

            if (items.Count > 0)
            {
                fetch.Options = new Request.ItemOperationsFetchOptions()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items            = items.ToArray()
                };
            }

            request.RequestData.Items = new object[] { fetch };

            return(request);
        }
예제 #22
0
        /// <summary>
        /// Call ItemOperations command to fetch an email in the specific folder.
        /// </summary>
        /// <param name="collectionId">The folder collection id to be fetched.</param>
        /// <param name="serverId">The ServerId of the item</param>
        /// <param name="bodyPartPreference">The BodyPartPreference element.</param>
        /// <param name="bodyPreference">The bodyPreference element.</param>
        /// <returns>An Email instance that includes the fetch result.</returns>
        protected Email ItemOperationsFetch(string collectionId, string serverId, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            ItemOperationsRequest  itemOperationsRequest  = TestSuiteHelper.GetItemOperationsRequest(collectionId, serverId, bodyPartPreference, bodyPreference);
            ItemOperationsResponse itemOperationsResponse = this.CONAdapter.ItemOperations(itemOperationsRequest);

            Site.Assert.AreEqual("1", itemOperationsResponse.ResponseData.Status, "The ItemOperations operation should be success.");

            ItemOperationsStore itemOperationsStore = Common.LoadItemOperationsResponse(itemOperationsResponse);

            Site.Assert.AreEqual(1, itemOperationsStore.Items.Count, "Only one email is supposed to be fetched.");
            Site.Assert.AreEqual("1", itemOperationsStore.Items[0].Status, "The fetch result should be success.");
            Site.Assert.IsNotNull(itemOperationsStore.Items[0].Email, "The fetched email should not be null.");

            return(itemOperationsStore.Items[0].Email);
        }
예제 #23
0
        /// <summary>
        /// Get the request of ItemOperations command.
        /// </summary>
        /// <param name="collectionId">The collection id of the folder to fetch.</param>
        /// <param name="serverId">The server id of the mail.</param>
        /// <param name="bodyPartPreference">The BodyPartPreference in the Options element.</param>
        /// <param name="bodyPreference">The BodyPreference in the Options element.</param>
        /// <returns>An ItemOperations command request.</returns>
        internal static ItemOperationsRequest GetItemOperationsRequest(string collectionId, string serverId, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            ItemOperationsRequest request = new ItemOperationsRequest {
                RequestData = new Request.ItemOperations()
            };

            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                Store        = SearchName.Mailbox.ToString(),
                CollectionId = collectionId,
                ServerId     = serverId
            };

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType5> itemsElementName = new List <Request.ItemsChoiceType5>();

            if (bodyPreference != null)
            {
                items.Add(bodyPreference);
                itemsElementName.Add(Request.ItemsChoiceType5.BodyPreference);
            }

            if (bodyPartPreference != null)
            {
                items.Add(bodyPartPreference);
                itemsElementName.Add(Request.ItemsChoiceType5.BodyPartPreference);
            }

            if (items.Count > 0)
            {
                fetch.Options = new Request.ItemOperationsFetchOptions()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items            = items.ToArray()
                };
            }

            request.RequestData.Items = new object[] { fetch };

            return(request);
        }
        /// <summary>
        /// Get the request of ItemOperations command.
        /// </summary>
        /// <param name="collectionId">The collection id of the folder to fetch.</param>
        /// <param name="serverId">The server id of the mail.</param>
        /// <param name="bodyPartPreference">The BodyPartPreference in the Options element.</param>
        /// <param name="bodyPreference">The BodyPreference in the Options element.</param>
        /// <returns>An ItemOperations command request.</returns>
        internal static ItemOperationsRequest GetItemOperationsRequest(string collectionId, string serverId, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            ItemOperationsRequest request = new ItemOperationsRequest { RequestData = new Request.ItemOperations() };
            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                Store = SearchName.Mailbox.ToString(),
                CollectionId = collectionId,
                ServerId = serverId
            };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType5> itemsElementName = new List<Request.ItemsChoiceType5>();

            if (bodyPreference != null)
            {
                items.Add(bodyPreference);
                itemsElementName.Add(Request.ItemsChoiceType5.BodyPreference);
            }

            if (bodyPartPreference != null)
            {
                items.Add(bodyPartPreference);
                itemsElementName.Add(Request.ItemsChoiceType5.BodyPartPreference);
            }

            if (items.Count > 0)
            {
                fetch.Options = new Request.ItemOperationsFetchOptions()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items = items.ToArray()
                };
            }

            request.RequestData.Items = new object[] { fetch };

            return request;
        }
예제 #25
0
        /// <summary>
        /// Call ItemOperations command to move a conversation to a folder.
        /// </summary>
        /// <param name="conversationId">The Id of conversation to be moved.</param>
        /// <param name="destinationFolder">The destination folder id.</param>
        /// <param name="moveAlways">Should future messages always be moved.</param>
        /// <returns>An instance of the ItemOperationsResponse.</returns>
        protected ItemOperationsResponse ItemOperationsMove(string conversationId, string destinationFolder, bool moveAlways)
        {
            Request.ItemOperationsMove move = new Request.ItemOperationsMove
            {
                DstFldId       = destinationFolder,
                ConversationId = conversationId
            };

            if (moveAlways)
            {
                move.Options = new Request.ItemOperationsMoveOptions {
                    MoveAlways = string.Empty
                };
            }

            ItemOperationsRequest  itemOperationRequest  = Common.CreateItemOperationsRequest(new object[] { move });
            ItemOperationsResponse itemOperationResponse = this.CONAdapter.ItemOperations(itemOperationRequest);

            Site.Assert.AreEqual("1", itemOperationResponse.ResponseData.Status, "The ItemOperations operation should be success.");
            Site.Assert.AreEqual(1, itemOperationResponse.ResponseData.Response.Move.Length, "The server should return one Move element in ItemOperationsResponse.");

            return(itemOperationResponse);
        }
예제 #26
0
 /// <summary>
 /// Creates an empty ItemOperationsRequest instance
 /// </summary>
 /// <returns>An ItemOperationsRequest instance</returns>
 public static ItemOperationsRequest CreateItemOperationsRequest()
 {
     ItemOperationsRequest request = new ItemOperationsRequest();
     Request.ItemOperations requestData = new Request.ItemOperations();
     request.RequestData = requestData;
     return request;
 }
예제 #27
0
        public void MSASTASK_S02_TC01_RetrieveTaskItemWithItemOperations()
        {
            #region Call Sync command to create a task item

            Dictionary <Request.ItemsChoiceType8, object> taskItem = new Dictionary <Request.ItemsChoiceType8, object>();
            string subject = Common.GenerateResourceName(Site, "subject");
            taskItem.Add(Request.ItemsChoiceType8.Subject2, subject);

            #endregion

            #region Call Sync command to add the task to the server

            // add task
            SyncStore syncResponse = this.SyncAddTask(taskItem);
            Site.Assert.AreEqual <int>(1, int.Parse(syncResponse.AddResponses[0].Status), "Adding a task item to server should success.");
            SyncItem task = this.GetChangeItem(this.UserInformation.TasksCollectionId, subject);
            Site.Assert.IsNotNull(task.Task, "The task which subject is {0} should exist in server.", subject);
            ItemsNeedToDelete.Add(subject);

            #endregion

            #region Call ItemOperations command to fetch tasks

            syncResponse = this.SyncChanges(this.UserInformation.TasksCollectionId);

            List <string> serverIds = new List <string>();
            for (int i = 0; i < syncResponse.AddElements.Count; i++)
            {
                serverIds.Add(syncResponse.AddElements[i].ServerId);
            }

            Request.Schema schema = new Request.Schema
            {
                ItemsElementName = new Request.ItemsChoiceType4[1],
                Items            = new object[1]
            };
            schema.ItemsElementName[0] = Request.ItemsChoiceType4.Body;
            schema.Items[0]            = new Request.Body();

            Request.BodyPreference bodyReference = new Request.BodyPreference {
                Type = 1
            };

            ItemOperationsRequest itemOperationsRequest  = TestSuiteHelper.CreateItemOperationsFetchRequest(this.UserInformation.TasksCollectionId, serverIds, null, bodyReference, schema);
            ItemOperationsStore   itemOperationsResponse = this.TASKAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <string>("1", itemOperationsResponse.Status, "The ItemOperations response should be successful.");

            #endregion

            // Get task item that created in this case.
            ItemOperations taskReturnedInItemOperations = null;
            foreach (ItemOperations item in itemOperationsResponse.Items)
            {
                if (task.Task.Body.Data.ToString().Contains(item.Task.Body.Data))
                {
                    taskReturnedInItemOperations = item;
                }
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R356");

            // Verify MS-ASTASK requirement: MS-ASTASK_R356
            // If the Task item in response is not null, this requirement will be captured.
            Site.CaptureRequirementIfIsNotNull(
                taskReturnedInItemOperations.Task,
                356,
                @"[In ItemOperations Command Response] When a client uses an ItemOperations command request ([MS-ASCMD] section 2.2.2.8) to retrieve data from the server for one or more specific Task items, as specified in section 3.1.5.1, the server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8).");

            bool otherPropertiesNull = true;

            // Loop to verify if other properties except "Body" are not returned.
            foreach (System.Reflection.PropertyInfo propertyInfo in typeof(Task).GetProperties())
            {
                if (propertyInfo.Name != "Body")
                {
                    object value = propertyInfo.GetValue(taskReturnedInItemOperations.Task, null);
                    if (value != null)
                    {
                        otherPropertiesNull = false;
                        break;
                    }
                }
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R358");

            // Verify MS-ASTASK requirement: MS-ASTASK_R358
            // If the body of the Task item in response is not null, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                otherPropertiesNull,
                358,
                @"[In ItemOperations Command Response] If an itemoperations:Schema element ([MS-ASCMD] section 2.2.3.135) is included in the ItemOperations command request, then the elements returned in the ItemOperations command response MUST be restricted to the elements that were included as child elements of the itemoperations:Schema element in the command request.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R359");

            // Since MS-ASTASK_R358 is captured, this requirement can be captured.
            Site.CaptureRequirement(
                359,
                @"[In ItemOperations Command Response] Top-level Task class elements, as specified in section 2.2, MUST be returned as child elements of the itemoperations:Properties element ([MS-ASCMD] section 2.2.3.128) in the ItemOperations command response.");
        }
        public void MSASRM_S02_TC01_ItemOperations_RightsManagedEmailMessages()
        {
            this.CheckPreconditions();

            #region The client logs on User1's account, calls Settings command to get a templateID with all rights allowed.
            string templateID = this.GetTemplateID("MSASRM_AllRights_AllowedTemplate");
            #endregion

            #region The client logs on User1's account, calls SendMail command with the templateID to send a rights-managed e-mail message to User2, switches to User2, and calls FolderSync command.
            string subject = this.SendMailAndFolderSync(templateID, false, null);
            #endregion

            #region The client logs on User2's account, calls Sync command with RightsManagementSupport element set to true to synchronize changes of Inbox folder in User2's mailbox, and gets the decompressed and decrypted rights-managed e-mail message.
            Sync item = this.SyncEmail(subject, this.UserTwoInformation.InboxCollectionId, true, true);
            Site.Assert.IsNotNull(item, "The returned item should not be null.");
            Site.Assert.IsNull(item.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");
            Site.Assert.IsNotNull(item.Email.RightsManagementLicense, "The RightsManagementLicense element in expected rights-managed e-mail message should not be null.");
            Site.Assert.IsTrue(item.Email.RightsManagementLicense.ExportAllowed, "The ExportAllowed element in expected rights-managed e-mail message should be true.");
            #endregion

            #region The client logs on User2's account, calls ItemOperations command which contains the Fetch element without RemoveRightsManagementProtection element.
            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                CollectionId = this.UserTwoInformation.InboxCollectionId,
                Store        = SearchName.Mailbox.ToString(),
                ServerId     = item.ServerId,
                Options      = new Request.ItemOperationsFetchOptions
                {
                    Items            = new object[] { true },
                    ItemsElementName = new Request.ItemsChoiceType5[] { Request.ItemsChoiceType5.RightsManagementSupport }
                }
            };
            ItemOperationsRequest itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetch });
            ItemOperationsStore   itemOperationsStore   = this.ASRMAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <int>(1, itemOperationsStore.Items.Count, "There should be only 1 item fetched in ItemOperations command response.");
            ItemOperations itemOperations = itemOperationsStore.Items[0];
            Site.Assert.IsNotNull(itemOperations, "The returned item should not be null.");
            Site.Assert.IsNotNull(itemOperations.Email, "The expected rights-managed e-mail message should not be null.");
            Site.Assert.IsNull(itemOperations.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");
            Site.Assert.IsNotNull(itemOperations.Email.RightsManagementLicense, "The RightsManagementLicense element in expected rights-managed e-mail message should not be null.");
            #endregion

            #region The client logs on User2's account, calls ItemOperations command which contains the Fetch element with RemoveRightsManagementProtection element.
            fetch.RemoveRightsManagementProtection = string.Empty;
            itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetch });
            itemOperationsStore   = this.ASRMAdapter.ItemOperations(itemOperationsRequest);
            Site.Assert.AreEqual <int>(1, itemOperationsStore.Items.Count, "There should be only 1 item fetched in ItemOperations command response.");
            itemOperations = itemOperationsStore.Items[0];
            Site.Assert.IsNotNull(itemOperations, "The returned item should not be null.");
            Site.Assert.IsNotNull(itemOperations.Email, "The expected rights-managed e-mail message should not be null.");
            Site.Assert.IsNull(itemOperations.Email.Attachments, "The Attachments element in expected rights-managed e-mail message should be null.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASRM_R91");

            // Verify MS-ASRM requirement: MS-ASRM_R91
            // If the response contains RightsManagementLicense element as null, represents the rights management protection is removed from the e-mail.
            Site.CaptureRequirementIfIsNull(
                itemOperations.Email.RightsManagementLicense,
                91,
                @"[In RemoveRightsManagementProtection] If present, it[RemoveRightsManagementProtection] indicates that the client is removing the IRM protection from the e-mail.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASRM_R94");

            // Verify MS-ASRM requirement: MS-ASRM_R94
            // If the response contains RightsManagementLicense element as null, represents the rights management protection is removed from the e-mail.
            Site.CaptureRequirementIfIsNull(
                itemOperations.Email.RightsManagementLicense,
                94,
                @"[In RemoveRightsManagementProtection] IRM protection can only be removed from e-mail messages when the ExportAllowed element is set to TRUE.");
            #endregion
        }
        public void MSASCMD_S08_TC20_ItemOperations_Status16()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "Recipient Information cache is not supported when MS-ASProtocolVersion is 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call ItemOperations command which contains the EmptyFolderContents element without DeleteSubFolders element.
            ItemOperationsRequest itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsEmptyFolderContents
                        {
                            CollectionId = "RI"
                        }
                    }
                }
            };

            ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            Site.Assert.AreEqual<string>("1", itemOperationsResponse.ResponseData.Status, "The Status element of the ItemOperations response should be 1.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4167");

            // Verify MS-ASCMD requirement: MS-ASCMD_R4167
            Site.CaptureRequirementIfAreEqual<string>(
                "16",
                itemOperationsResponse.ResponseData.Response.EmptyFolderContents[0].Status,
                4167,
                @"[In Status(ItemOperations)] [The meaning of the status value] 16 [is] Access to the resource is denied.");

            #endregion
        }
예제 #30
0
        /// <summary>
        /// Build an ItemOperations command request.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The server id of the mail.</param>
        /// <param name="fileReference">The file reference of the attachment.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <returns>An ItemOperations command request.</returns>
        internal static ItemOperationsRequest CreateItemOperationsRequest(string collectionId, string serverId, string fileReference, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
        {
            ItemOperationsRequest request = new ItemOperationsRequest {
                RequestData = new Request.ItemOperations()
            };

            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch {
                Store = SearchName.Mailbox.ToString()
            };

            if (fileReference != null)
            {
                fetch.FileReference = fileReference;
            }
            else
            {
                fetch.CollectionId = collectionId;
                fetch.ServerId     = serverId;
            }

            List <object> items = new List <object>();
            List <Request.ItemsChoiceType5> itemsElementName = new List <Request.ItemsChoiceType5>();

            if (bodyPreferences != null)
            {
                foreach (Request.BodyPreference bodyPreference in bodyPreferences)
                {
                    items.Add(bodyPreference);
                    itemsElementName.Add(Request.ItemsChoiceType5.BodyPreference);

                    // Include the MIMESupport element in request to retrieve the MIME body
                    if (bodyPreference.Type == 4)
                    {
                        items.Add((byte)2);
                        itemsElementName.Add(Request.ItemsChoiceType5.MIMESupport);
                    }
                }
            }

            if (bodyPartPreferences != null)
            {
                foreach (Request.BodyPartPreference bodyPartPreference in bodyPartPreferences)
                {
                    items.Add(bodyPartPreference);
                    itemsElementName.Add(Request.ItemsChoiceType5.BodyPartPreference);
                }
            }

            if (items.Count > 0)
            {
                fetch.Options = new Request.ItemOperationsFetchOptions()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items            = items.ToArray()
                };
            }

            request.RequestData.Items = new object[] { fetch };

            return(request);
        }
예제 #31
0
 /// <summary>
 /// Creates an ItemOperationsRequest instance using specified items
 /// </summary>
 /// <param name="items">Specified object items array</param>
 /// <returns>An ItemOperationsRequest instance</returns>
 public static ItemOperationsRequest CreateItemOperationsRequest(object[] items)
 {
     ItemOperationsRequest request = new ItemOperationsRequest();
     Request.ItemOperations requestData = new Request.ItemOperations { Items = items };
     request.RequestData = requestData;
     return request;
 }
 /// <summary>
 /// Fetch all information about exchange object
 /// </summary>
 /// <param name="itemOperationsRequest">ItemOperations command request.</param>
 /// <returns>The ItemOperations result which is returned from server</returns>
 public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
 {
     ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
     this.VerifyItemOperationsResponse(response);
     ItemOperationsStore result = Common.LoadItemOperationsResponse(response);
     bool hasSchemaElement = AdapterHelper.ContainsSchemaElement(itemOperationsRequest);
     this.VerifyTransport();
     this.VerifyItemOperationResult(result, hasSchemaElement);
     this.VerifyWBXMLCapture();
     return result;
 }
        public void MSASCMD_S08_TC01_ItemOperations_DeleteSubFolders()
        {
            #region Call method FolderCreate to create a new folder as the child folder of the specified parent folder.
            // Create a user-created mail folder as a subfolder of Inbox folder.
            string subFolderName = Common.GenerateResourceName(Site, "subfolder");
            FolderCreateRequest folderCreateRequest = Common.CreateFolderCreateRequest(this.LastFolderSyncKey, (byte)FolderType.UserCreatedMail, subFolderName, this.User1Information.InboxCollectionId);
            FolderCreateResponse folderCreateResponse = this.CMDAdapter.FolderCreate(folderCreateRequest);

            Site.Assert.AreEqual<int>(
                1,
                int.Parse(folderCreateResponse.ResponseData.Status),
                "The Status element of the FolderCreate response should be 1.");

            // Record created folder CollectionId.
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderCreateResponse.ResponseData.ServerId);
            #endregion

            #region Call method FolderSync to synchronize the collection hierarchy and get CollectionId of the created subfolder.
            FolderSyncResponse folderSyncResponse = this.FolderSync();
            string subFolderId = Common.GetDefaultFolderServerId(folderSyncResponse, FolderType.UserCreatedMail, this.Site);
            Site.Assert.IsNotNull(subFolderId, "The CollectionId of the created child folder should not be null.");
            #endregion

            #region Call ItemOperations command which contains the EmptyFolderContents element without DeleteSubFolders element.
            ItemOperationsRequest itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsEmptyFolderContents
                        {
                            CollectionId = this.User1Information.InboxCollectionId
                        }
                    }
                }
            };

            ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            Site.Assert.AreEqual<string>("1", itemOperationsResponse.ResponseData.Status, "The Status element of the ItemOperations response should be 1.");

            #endregion

            #region Call method FolderSync to synchronize the collection hierarchy and check whether the subfolder exists.
            folderSyncResponse = this.FolderSync();

            Site.Assert.IsNotNull(folderSyncResponse.ResponseData.Changes, "The Changes element of the FolderSync Response should not be null.");
            Response.FolderSyncChangesAdd[] folderChangesAdds = folderSyncResponse.ResponseData.Changes.Add;

            bool subFolderExists = false;
            foreach (Response.FolderSyncChangesAdd folderChangesAdd in folderChangesAdds)
            {
                if (folderChangesAdd.DisplayName == subFolderName && folderChangesAdd.ParentId == this.User1Information.InboxCollectionId)
                {
                    subFolderId = folderChangesAdd.ServerId;
                    subFolderExists = true;
                    break;
                }
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2167, Expected subfolder name: {0}, parent folder's CollectionId: {1}, subfolder's ServerId: {2}", subFolderName, this.User1Information.InboxCollectionId, subFolderId);

            // Verify MS-ASCMD requirement: MS-ASCMD_R2167
            // If the user-created mail subfolder can be found, and ServerId is the same with the one after created, this requirement can be verified.
            Site.CaptureRequirementIfIsTrue(
                subFolderExists,
                2167,
                @"[In DeleteSubFolders] If the DeleteSubFolders element is not present in the request, the default behavior is to not delete subfolders.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2244");

            // Verify MS-ASCMD requirement: MS-ASCMD_R2244
            // This requirement can be captured directly after MS-ASCMD_R2167
            Site.CaptureRequirement(
                2244,
                @"[In EmptyFolderContents] If the DeleteSubFolders option is not included in the request, the subfolders of the specified airsync:CollectionId are not deleted.");
            #endregion

            #region Call ItemOperations command which contains the EmptyFolderContents element with DeleteSubFolders element.
            itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsEmptyFolderContents
                        {
                            CollectionId = this.User1Information.InboxCollectionId,
                            Options = new Request.ItemOperationsEmptyFolderContentsOptions
                            {
                                DeleteSubFolders = string.Empty
                            }
                        }
                    }
                }
            };

            itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            Site.Assert.AreEqual<string>("1", itemOperationsResponse.ResponseData.Status, "The Status element of the ItemOperations response should be 1.");

            // Remove the recorded user name and its corresponding folder's CollectionId.
            this.User1Information.UserCreatedFolders.Clear();
            #endregion

            #region Call method FolderSync to synchronize the collection hierarchy and check whether the subfolder exists.
            folderSyncResponse = this.FolderSync();

            Site.Assert.IsNotNull(folderSyncResponse.ResponseData.Changes, "The Changes element of the FolderSync Response should not be null.");
            folderChangesAdds = folderSyncResponse.ResponseData.Changes.Add;

            subFolderExists = false;
            foreach (Response.FolderSyncChangesAdd folderChangesAdd in folderChangesAdds)
            {
                if (folderChangesAdd.DisplayName == subFolderName && folderChangesAdd.ParentId == this.User1Information.InboxCollectionId)
                {
                    subFolderExists = true;
                    break;
                }
            }

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2243");

            // Verify MS-ASCMD requirement: MS-ASCMD_R2243
            // If the user-created mail subfolder cannot be found, this requirement can be verified.
            Site.CaptureRequirementIfIsFalse(
                subFolderExists,
                2243,
                @"[In EmptyFolderContents] The element supports a single child element of the Options element, the DeleteSubFolders element (section 2.2.3.44), which determines whether subfolders contained in the folder are deleted.");
            #endregion
        }
        /// <summary>
        /// Create ItemOperations request with only Fetch element
        /// </summary>
        /// <param name="collectionId">The CollectionId of a folder</param>
        /// <param name="store">The store on which to do ItemOperations method</param>
        /// <param name="serverId">The ServerId of an Item</param>
        /// <param name="options">The Options element in ItemOperations request</param>
        /// <returns>The request of ItemOperations method</returns>
        private static ItemOperationsRequest CreateItemOperationsRequestWithFetchElement(string collectionId, string store, string serverId, Request.ItemOperationsFetchOptions options)
        {
            ItemOperationsRequest itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsFetch
                        {
                            CollectionId = collectionId,
                            Store = store,
                            ServerId = serverId,
                            Options = options
                        }
                    }
                }
            };

            return itemOperationsRequest;
        }
        /// <summary>
        /// Build an ItemOperations command request.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The server id of the mail.</param>
        /// <param name="fileReference">The file reference of the attachment.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <returns>An ItemOperations command request.</returns>
        internal static ItemOperationsRequest CreateItemOperationsRequest(string collectionId, string serverId, string fileReference, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
        {
            ItemOperationsRequest request = new ItemOperationsRequest { RequestData = new Request.ItemOperations() };
            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch { Store = SearchName.Mailbox.ToString() };

            if (fileReference != null)
            {
                fetch.FileReference = fileReference;
            }
            else
            {
                fetch.CollectionId = collectionId;
                fetch.ServerId = serverId;
            }

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType5> itemsElementName = new List<Request.ItemsChoiceType5>();

            if (bodyPreferences != null)
            {
                foreach (Request.BodyPreference bodyPreference in bodyPreferences)
                {
                    items.Add(bodyPreference);
                    itemsElementName.Add(Request.ItemsChoiceType5.BodyPreference);

                    // Include the MIMESupport element in request to retrieve the MIME body
                    if (bodyPreference.Type == 4)
                    {
                        items.Add((byte)2);
                        itemsElementName.Add(Request.ItemsChoiceType5.MIMESupport);
                    }
                }
            }

            if (bodyPartPreferences != null)
            {
                foreach (Request.BodyPartPreference bodyPartPreference in bodyPartPreferences)
                {
                    items.Add(bodyPartPreference);
                    itemsElementName.Add(Request.ItemsChoiceType5.BodyPartPreference);
                }
            }

            if (items.Count > 0)
            {
                fetch.Options = new Request.ItemOperationsFetchOptions()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items = items.ToArray()
                };
            }

            request.RequestData.Items = new object[] { fetch };

            return request;
        }
예제 #36
0
        internal ItemOperationsResponse LookupItems(IReadOnlyCollection <string> messageIds, string folderId)
        {
            ItemOperationsRequest itemOperationsRequest = EasRequestGenerator.CreateItemOpsRequestForSelectedMessages(messageIds, folderId);

            return(this.ItemOperations(itemOperationsRequest));
        }
예제 #37
0
 private ItemOperationsResponse ItemOperations(ItemOperationsRequest itemOperationsRequest)
 {
     return(EasConnectionWrapper.WrapException <ItemOperationsResponse>(() => this.wrappedObject.ItemOperations(itemOperationsRequest), (ConnectionsTransientException e) => new EasFetchFailedTransientException(e.Message, e), (ConnectionsPermanentException e) => new EasFetchFailedPermanentException(e.Message, e)));
 }
        public void MSASCMD_S08_TC09_ItemOperations_RecipientInformationCache()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The recipient information cache is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Call ItemOperations command which contains the EmptyFolderContents element on recipient information cache, and check the Status element for this operation.
            ItemOperationsRequest itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsEmptyFolderContents
                        {
                            CollectionId = this.User1Information.RecipientInformationCacheCollectionId
                        }
                    }
                }
            };

            ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            Site.Assert.AreEqual<string>("1", itemOperationsResponse.ResponseData.Status, "The Status element of the ItemOperations response should be 1.");

            Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response, "The Response element of the ItemOperations response should not be null.");
            Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response.EmptyFolderContents, "The EmptyFolderContents element of the ItemOperations response should not be null.");
            Site.Assert.AreEqual<int>(1, itemOperationsResponse.ResponseData.Response.EmptyFolderContents.Length, "The length of EmptyFolderContents element array should be 1.");
            Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response.EmptyFolderContents[0], "The EmptyFolderContents element of the ItemOperations response should not be null.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R196");

            // Verify MS-ASCMD requirement: MS-ASCMD_R196
            // If the status is not 1, which means the operation is not successful.
            Site.CaptureRequirementIfAreNotEqual<string>(
                "1",
                itemOperationsResponse.ResponseData.Response.EmptyFolderContents[0].Status,
                196,
                @"[In ItemOperations] The ItemOperations command cannot perform operations on items in the recipient information cache.");
            #endregion
        }
예제 #39
0
        public void MSASDOC_S02_TC01_ItemOperations_WithoutMultipart()
        {
            #region Client calls ItemOperations command to get data of a shared visible document.

            // Build element Fetch.
            ItemOperationsFetch fetchElement = this.FetchElementBuilder(Common.GetConfigurationPropertyValue("SharedVisibleDocument", Site));

            // Create an ItemOperation command request.
            ItemOperationsRequest itemOperationsRequest = Common.CreateItemOperationsRequest(new object[] { fetchElement });

            // Send request and get response.
            ItemOperationsResponse itemOperationResponse = this.ASDOCAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            Site.Assert.AreEqual <int>(1, itemOperationResponse.ResponseData.Response.Fetch.Length, "Only one document's information should be returned.");
            Site.Assert.AreEqual <string>("1", itemOperationResponse.ResponseData.Response.Fetch[0].Status, "The call should be successful.");

            #endregion

            // Multipart responses have a Content-Type header with the value "application/vnd.ms-sync.multipart".
            bool isMultiPartResponse = itemOperationResponse.Headers.ToString().Contains("application/vnd.ms-sync.multipart");

            bool existDataElement = false;

            foreach (Response.ItemsChoiceType3 itemsElementName in itemOperationResponse.ResponseData.Response.Fetch[0].Properties.ItemsElementName)
            {
                if (itemsElementName == Response.ItemsChoiceType3.Data)
                {
                    existDataElement = true;
                    break;
                }
            }

            Site.Assert.IsTrue(existDataElement, "itemoperations:Data element should be returned");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R69, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R69
            // If itemoperations:Data element is successfully returned, the body has been decoded from base64 encoding.
            Site.CaptureRequirement(
                69,
                @"[In Requesting the Document Body from the Server] The body of the document is returned as [either] text encoded with base64 encoding in the itemoperations:Data element ([MS-ASCMD] section 2.2.3.39.1) of the ItemOperations command response [or as binary data], depending on the content type that the client requested.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R77, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R77
            Site.CaptureRequirementIfIsFalse(
                isMultiPartResponse,
                77,
                @"[In ItemOperations Command Request] If this header[the HTTP header (2) MS-ASAcceptMultiPart: T] is not used, the document data is returned as text.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R98, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R98
            // If itemoperations:Data element is successfully returned, the body has been decoded from base64 encoding.
            Site.CaptureRequirementIfIsFalse(
                isMultiPartResponse,
                98,
                @"[In Retrieving the Document Body] The server responds with an ItemOperations command response ([MS-ASCMD] section 2.2.2.8), which returns the body of the document as text encoded with base64 encoding in the itemoperations:Data element ([MS-ASCMD] section 2.2.2.8) of the response if the command request was not a multi-part request.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASDOC_R107, header value is:{0}", itemOperationResponse.Headers.ToString());

            // Verify MS-ASDOC requirement: MS-ASDOC_R107
            // If itemoperations:Data element is successfully returned, the body has been decoded from base64 encoding.
            Site.CaptureRequirementIfIsFalse(
                isMultiPartResponse,
                107,
                @"[In ItemOperations Command Response] Otherwise[an ItemOperations command request for the body of the document was not made using the MS-ASAcceptMultiPart: T header (2) ], the server MUST transmit the document as data encoded with base64 encoding within the itemoperations:Data element ([MS-ASCMD] section 2.2.3.39.1) of the ItemOperations command response.");
        }
        /// <summary>
        /// Delete all items from the specified collection
        /// </summary>
        /// <param name="collectionId">The specified collection id</param>
        private void DeleteAll(string collectionId)
        {
            ItemOperationsRequest request = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations()
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsEmptyFolderContents
                        {
                            CollectionId = collectionId,
                            Options = new Request.ItemOperationsEmptyFolderContentsOptions
                            {
                                DeleteSubFolders = string.Empty
                            }
                        }
                    }
                }
            };

            ItemOperationsResponse response = this.CMDAdapter.ItemOperations(request, DeliveryMethodForFetch.Inline);
            Site.Assert.IsTrue(response.ResponseData != null && response.ResponseData.Status == "1" && response.ResponseData.Response.EmptyFolderContents[0].Status == "1", "All items in the specified collection should be deleted successfully.");
        }
        /// <summary>
        /// Fetch all the data about tasks.
        /// </summary>
        /// <param name="itemOperationsRequest">An ItemOperations command request.</param>
        /// <returns>An ItemOperations command response returned from the server.</returns>
        public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            Site.Assert.IsNotNull(response, "The ItemOperations response should be returned.");
            ItemOperationsStore itemOperationResponse = Common.LoadItemOperationsResponse(response);
            this.VerifyItemOperationsResponse(itemOperationResponse);

            return itemOperationResponse;
        }
 /// <summary>
 /// Fetch all information about exchange object.
 /// </summary>
 /// <param name="itemOperationsRequest">The request for itemOperations.</param>
 /// <returns>The ItemOperations result which is returned from server.</returns>
 public ItemOperationsStore ItemOperations(ItemOperationsRequest itemOperationsRequest)
 {
     ItemOperationsResponse response = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
     Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null.");
     ItemOperationsStore result = Common.LoadItemOperationsResponse(response);
     this.VerifyTransport();
     this.VerifyItemOperations(result);
     this.VerifyWBXMLCapture();
     return result;
 }
        public void MSASCMD_S08_TC10_ItemOperations_EmptyFolderContents()
        {
            #region Create a sub-folder in User1's Contacts folder.
            string folderId = this.CreateFolder((byte)FolderType.UserCreatedContacts, Common.GenerateResourceName(Site, "FolderCreate"), this.User1Information.ContactsCollectionId);
            Site.Assert.IsFalse(string.IsNullOrEmpty(folderId), "The sub-folder should be created successfully under the Contacts' folder.");
            TestSuiteBase.RecordCaseRelativeFolders(this.User1Information, folderId);
            this.FolderSync();
            #endregion

            #region Add a new contact with Sync operation.
            string contactFileAS = Common.GenerateResourceName(Site, "FileAS");
            Request.SyncCollectionAdd addData = this.CreateAddContactCommand("FirstName", "MiddleName", "LastName", contactFileAS, null);
            this.Sync(TestSuiteBase.CreateEmptySyncRequest(folderId));
            SyncRequest syncRequest = TestSuiteBase.CreateSyncAddRequest(this.LastSyncKey, folderId, addData);
            SyncResponse syncResponse = this.Sync(syncRequest, false);
            Site.Assert.IsNotNull(syncResponse.ResponseData.Item, "The items returned in the Sync command response should not be null.");
            Response.SyncCollectionsCollectionResponses collectionResponse = TestSuiteBase.GetCollectionItem(syncResponse, Response.ItemsChoiceType10.Responses) as Response.SyncCollectionsCollectionResponses;
            Site.Assert.IsNotNull(collectionResponse, "The responses element should exist in the Sync response.");
            Site.Assert.AreEqual<string>("1", collectionResponse.Add[0].Status, "The new contact should be added correctly.");
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, folderId, contactFileAS);
            #endregion

            #region Call ItemOperations command which contains the EmptyFolderContents element.
            ItemOperationsRequest itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsEmptyFolderContents
                        {
                            CollectionId = folderId
                        }
                    }
                }
            };

            ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            Site.Assert.AreEqual<string>("1", itemOperationsResponse.ResponseData.Status, "The Status element of the ItemOperations response should be 1.");
            #endregion

            #region Verify if the contact has been removed from User1's Contacts folder.
            syncResponse = this.SyncChanges(folderId);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R199");

            // If the EmptyFolderContents operation enables the client to empty a folder of all its items, all items will be deleted form the specified folder.
            // Verify MS-ASCMD requirement: MS-ASCMD_R199
            Site.CaptureRequirementIfIsNull(
                syncResponse.ResponseData.Item,
                199,
                @"[In ItemOperations] The EmptyFolderContents operation enables the client to empty a folder of all its items.");

            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, folderId, contactFileAS);
            #endregion
        }
        /// <summary>
        /// Create an ItemOperations command request.
        /// </summary>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="serverId">The serverId of the item.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <param name="schema">Sets the schema information.</param>
        /// <returns>An ItemOperations command request.</returns>
        internal static ItemOperationsRequest CreateItemOperationsRequest(string collectionId, string serverId, Request.BodyPreference bodyPreference, Request.Schema schema)
        {
            ItemOperationsRequest request = new ItemOperationsRequest { RequestData = new Request.ItemOperations() };
            Request.ItemOperationsFetch fetch = new Request.ItemOperationsFetch
            {
                Store = SearchName.Mailbox.ToString(),
                CollectionId = collectionId,
                ServerId = serverId
            };

            List<object> items = new List<object>();
            List<Request.ItemsChoiceType5> itemsElementName = new List<Request.ItemsChoiceType5>();

            if (null != schema)
            {
                itemsElementName.Add(Request.ItemsChoiceType5.Schema);
                items.Add(schema);
            }

            if (null != bodyPreference)
            {
                itemsElementName.Add(Request.ItemsChoiceType5.BodyPreference);
                items.Add(bodyPreference);

                if (bodyPreference.Type == 0x4)
                {
                    itemsElementName.Add(Request.ItemsChoiceType5.MIMESupport);

                    // '2' indicates server sends MIME data for all messages but not S/MIME messages only
                    items.Add((byte)0x2);
                }
            }

            if (items.Count > 0)
            {
                fetch.Options = new Request.ItemOperationsFetchOptions()
                {
                    ItemsElementName = itemsElementName.ToArray(),
                    Items = items.ToArray()
                };
            }

            request.RequestData.Items = new object[] { fetch };

            return request;
        }
예제 #45
0
        ItemOperationsResponse IEasConnection.ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsCommand itemOperationsCommand = new ItemOperationsCommand(this.EasConnectionSettings);

            return(itemOperationsCommand.Execute(itemOperationsRequest));
        }
예제 #46
0
        public void MSASAIRS_S04_TC05_IncorrectPlacement()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);
            #endregion

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type                    = 1,
                    TruncationSize          = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone               = true,
                    AllOrNoneSpecified      = true
                }
            };
            #endregion

            #region Call ItemOperations command with incorrect placement of BodyPreference element.
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, bodyPreference, null);

            if (Common.IsRequirementEnabled(10032, this.Site))
            {
                ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsRequest(this.User2Information.InboxCollectionId, syncItem.ServerId, null, bodyPreference, null);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(itemOperationRequest.GetRequestDataSerializedXML());
                XmlNode bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");

                // Add another BodyPreference element in the BodyPreference element, the placement is invalid.
                XmlNode temp = bodyPreferenceNode.Clone();
                temp.SelectSingleNode("//*[name()='Type']").InnerText = "2";
                bodyPreferenceNode.AppendChild(temp);

                SendStringResponse itemOperationResponse = this.ASAIRSAdapter.ItemOperations(doc.OuterXml);

                string status = this.GetStatusCodeFromXPath(itemOperationResponse, "/i:ItemOperations/i:Status");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R10032");

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10032
                Site.CaptureRequirementIfAreEqual(
                    "2",
                    status,
                    10032,
                    @"[In Appendix B: Product Behavior] Implementation does return protocol status error 2 for an ItemOperations command (as specified in [MS-ASCMD] section 2.2.2.8), if an element does not meet the requirements[any of the XML elements specified in section 2.2.2 that are present in the command's XML body to ensure they comply with the requirements regarding placement] specified for that element, unless specified in the following table[section 3.2.5.1]. (Exchange Server 2007 SP1 and above follow this behavior.)");
            }
            #endregion

            #region Call Search command with incorrect placement of BodyPreference element.
            if (Common.IsRequirementEnabled(10036, this.Site))
            {
                SearchRequest searchRequest = TestSuiteHelper.CreateSearchRequest(subject, this.User2Information.InboxCollectionId, null, bodyPreference, null);
                XmlDocument   doc           = new XmlDocument();
                doc.LoadXml(searchRequest.GetRequestDataSerializedXML());
                XmlNode bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");

                // Add another BodyPreference element in the BodyPreference element, the placement is invalid.
                XmlNode temp = bodyPreferenceNode.Clone();
                temp.SelectSingleNode("//*[name()='Type']").InnerText = "2";
                bodyPreferenceNode.AppendChild(temp);

                SendStringResponse searchResponse = this.ASAIRSAdapter.Search(doc.OuterXml);
                string             searchStatus   = this.GetStatusCodeFromXPath(searchResponse, "/s:Search/s:Status");
                int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
                int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
                int counter    = 1;

                while (counter < retryCount && searchStatus.Equals("10"))
                {
                    Thread.Sleep(waitTime);
                    searchResponse = this.ASAIRSAdapter.Search(doc.OuterXml);
                    searchStatus   = this.GetStatusCodeFromXPath(searchResponse, "/s:Search/s:Status");
                    counter++;
                }

                string status = this.GetStatusCodeFromXPath(searchResponse, "/s:Search/s:Response/s:Store/s:Status");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R10036");

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10036
                Site.CaptureRequirementIfAreEqual(
                    "2",
                    status,
                    10036,
                    @"[In Appendix B: Product Behavior] Implementation does return protocol status error 2 for a Search command (as specified in [MS-ASCMD] section 2.2.2.14), if an element does not meet the requirements[any of the XML elements specified in section 2.2.2 that are present in the command's XML body to ensure they comply with the requirements regarding placement] specified for that element, unless specified in the following table[section 3.2.5.1]. (Exchange Server 2007 SP1 and above follow this behavior.)");
            }
            #endregion

            #region Call Sync add command with incorrect placement of Type element.
            if (Common.IsRequirementEnabled(10039, this.Site))
            {
                SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, CreateSyncAddCommands(), null, null);
                XmlDocument doc            = new XmlDocument();
                doc.LoadXml(syncAddRequest.GetRequestDataSerializedXML());
                XmlNode bodyNode = doc.SelectSingleNode("//*[name()='Body']");

                // Add another body element in the body element, the placement is invalid.
                XmlNode temp = bodyNode.Clone();
                temp.SelectSingleNode("//*[name()='Type']").InnerText = "2";
                bodyNode.AppendChild(temp);

                SendStringResponse syncAddResponse = this.ASAIRSAdapter.Sync(doc.OuterXml);

                string status = this.GetStatusCodeFromXPath(syncAddResponse, "/a:Sync/a:Collections/a:Collection/a:Responses/a:Add/a:Status");

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R10039");

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10039
                Site.CaptureRequirementIfAreEqual(
                    "6",
                    status,
                    10039,
                    @"[In Appendix B: Product Behavior] Implementation does return protocol status error 6 for a Sync command (as specified in [MS-ASCMD] section 2.2.2.19), if an element does not meet the requirements[any of the XML elements specified in section 2.2.2 that are present in the command's XML body to ensure they comply with the requirements regarding placement] specified for that element, unless specified in the following table[section 3.2.5.1]. (Exchange Server 2007 SP1 and above follow this behavior.)");
            }
            #endregion
        }
        /// <summary>
        /// Acts as a container for the Fetch element, the EmptyFolderContents element, and the Move element to provide batched online handling of these operations against the server.
        /// </summary>
        /// <param name="itemOperationsRequest">An ItemOperationsRequest object that contains the request information.</param>
        /// <returns>ItemOperations command response.</returns>
        public ItemOperationsResponse ItemOperations(ItemOperationsRequest itemOperationsRequest)
        {
            ItemOperationsResponse itemOperationsResponse = this.activeSyncClient.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            Site.Assert.IsNotNull(itemOperationsResponse, "The ItemOperations response returned from server should not be null.");

            // Verify related requirements.
            this.VerifyCommonRequirements();
            this.VerifyWBXMLCapture();
            this.VerifyItemOperationsCommandResponse(itemOperationsResponse);

            return itemOperationsResponse;
        }
        public void MSASCMD_S08_TC19_ItemOperations_Status156()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Move element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region User2 sends mail to User1 and does FolderSync in User1's mailbox.
            string subject = this.SendMailAndFolderSync();
            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server.
            SyncResponse syncResponse = this.GetMailItem(this.User1Information.InboxCollectionId, subject);
            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", subject);
            string conversationId = GetConverstationIdFromSyncResposne(syncResponse, serverId);
            #endregion

            #region Call method ItemOperations which contains the Move element.
            ItemOperationsRequest itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsMove
                        {
                            ConversationId = conversationId,
                            DstFldId = this.User1Information.NotesCollectionId,
                            Options = new Request.ItemOperationsMoveOptions
                            {
                                MoveAlways = string.Empty
                            }
                        }
                    }
                }
            };

            ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response, "The Response element of the ItemOperations response should not be null.");
            Site.Assert.AreEqual<string>("1", itemOperationsResponse.ResponseData.Status, @"The Status element of the ItemOperations response should be 1.");
            Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response.Move, "The Move element of the ItemOperations response should not be null.");
            Site.Assert.AreEqual<int>(1, itemOperationsResponse.ResponseData.Response.Move.Length, "The length of Move element array should be 1.");
            Site.Assert.IsNotNull(itemOperationsResponse.ResponseData.Response.Move[0], "The first Move element of the ItemOperations response should not be null.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R4942");

            // Verify MS-ASCMD requirement: MS-ASCMD_R4942
            Site.CaptureRequirementIfAreEqual<string>(
                "156",
                itemOperationsResponse.ResponseData.Response.Move[0].Status,
                4942,
                @"[In Common Status Codes] [The meaning of the status value 156 is] The destination folder for the move is invalid.");
            #endregion
        }
        public void MSASCMD_S08_TC06_ItemOperations_Move()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Move element is not supported when the MS-ASProtocolVersion header is set to 12.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region User2 sends mail to User1 and does FolderSync in User1's mailbox.
            string subject = this.SendMailAndFolderSync();
            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User1's mailbox between the client and the server.
            SyncResponse syncResponse = this.GetMailItem(this.User1Information.InboxCollectionId, subject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.InboxCollectionId, subject);
            string serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", subject);
            string conversationId = GetConverstationIdFromSyncResposne(syncResponse, serverId);
            #endregion

            #region Call method ItemOperations which contains the Move element.
            ItemOperationsRequest itemOperationsRequest = new ItemOperationsRequest
            {
                RequestData = new Request.ItemOperations
                {
                    Items = new object[]
                    {
                        new Request.ItemOperationsMove
                        {
                            ConversationId = conversationId,
                            DstFldId = this.User1Information.DeletedItemsCollectionId,
                            Options = new Request.ItemOperationsMoveOptions
                            {
                                MoveAlways = string.Empty
                            }
                        }
                    }
                }
            };

            ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);

            // Record user name, folder's CollectionId and item subject that are used in this case.
            syncResponse = this.GetMailItem(this.User1Information.DeletedItemsCollectionId, subject);
            serverId = TestSuiteBase.FindServerId(syncResponse, "Subject", subject);
            Site.Assert.IsNotNull(serverId, "The serverId of expected item should not be null");
            TestSuiteBase.RemoveRecordCaseRelativeItems(this.User1Information, this.User1Information.InboxCollectionId, subject);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, this.User1Information.DeletedItemsCollectionId, subject);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R201");

            // Verify MS-ASCMD requirement: MS-ASCMD_R201
            Site.CaptureRequirementIfAreEqual<string>(
                 "1",
                itemOperationsResponse.ResponseData.Status,
                201,
                @"[In ItemOperations] The Move operation moves a conversation to a destination folder.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3465");

            // Verify MS-ASCMD requirement: MS-ASCMD_R3465
            Site.CaptureRequirementIfAreEqual<string>(
                 "1",
                itemOperationsResponse.ResponseData.Status,
                3465,
                @"[In Move(ItemOperations)] It [Move element] identifies the body of the request or response as containing the operation that moves a given conversation.<52>");
            #endregion
        }