示例#1
0
        public void MSASCON_S01_TC08_Sync_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 sync command with BodyPartPreference element and set the Type element to 3
            this.SwitchUser(this.User1Information, false);

            // Check whether the mail has been received.
            this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, null);

            Request.BodyPartPreference bodyPartPreference = new Request.BodyPartPreference()
            {
                Type = 3,
            };

            // Call initial Sync command.
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(User1Information.InboxCollectionId);
            SyncStore   syncStore   = this.CONAdapter.Sync(syncRequest);

            syncRequest = TestSuiteHelper.GetSyncRequest(User1Information.InboxCollectionId, syncStore.SyncKey, bodyPartPreference, null, false);
            syncStore   = this.CONAdapter.Sync(syncRequest);
            this.VerifyMessagePartStatus164(syncStore.Status);
            #endregion
        }
        /// <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);
        }
示例#3
0
        /// <summary>
        /// Get the non-truncated item data.
        /// </summary>
        /// <param name="subject">The subject of the item.</param>
        /// <param name="collectionId">The server id of the folder which contains the specified item.</param>
        /// <returns>The item with non-truncated data.</returns>
        protected DataStructures.Sync GetAllContentItem(string subject, string collectionId)
        {
            Request.BodyPartPreference[] bodyPartPreference = null;

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1") &&
                !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.0"))
            {
                // Set the BodyPartPreference element to retrieve the BodyPart element in response
                bodyPartPreference = new Request.BodyPartPreference[]
                {
                    new Request.BodyPartPreference()
                    {
                        Type = 2
                    }
                };
            }

            // Set the BodyPreference element to retrieve the Body element in response
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 1
                }
            };

            // Get the item with specified subject
            DataStructures.Sync item = this.GetSyncResult(subject, collectionId, null, bodyPreference, bodyPartPreference);

            this.Site.Assert.IsNotNull(item.Email.Body, "The Body element should be included in Sync command response when the BodyPreference element is specified in Sync command request.");

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1") &&
                !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.0"))
            {
                this.Site.Assert.IsNotNull(
                    item.Email.BodyPart,
                    "The BodyPart element should be included in Sync command response when the BodyPartPreference element is specified in Sync command request.");

                this.Site.Assert.AreEqual <byte>(
                    1,
                    item.Email.BodyPart.Status,
                    "The Status should be 1 to indicate the success of the Sync command response in returning Data element content given the BodyPartPreference element settings in the Sync command request.");
            }

            return(item);
        }
        public void MSASAIRS_S01_TC08_BodyPart_Preview()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email and get the none truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);

            DataStructures.Sync allContentItem = this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            #endregion

            #region Set BodyPartPreference element
            Request.BodyPartPreference[] bodyPartPreference = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    Preview = 18,
                    PreviewSpecified = true
                }
            };
            #endregion

            #region Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreference);

            this.VerifyBodyPartPreview(syncItem.Email, allContentItem.Email, bodyPartPreference);
            #endregion

            #region Verify ItemOperations command related elements
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, bodyPartPreference, null);

            this.VerifyBodyPartPreview(itemOperationsItem.Email, allContentItem.Email, bodyPartPreference);
            #endregion

            #region Verify Search command related elements
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, bodyPartPreference);

            this.VerifyBodyPartPreview(searchItem.Email, allContentItem.Email, bodyPartPreference);
            #endregion

            #region Verify requirements
            // According to above steps, the following requirements can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R256");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R256
            Site.CaptureRequirement(
                256,
                @"[In Preview (BodyPart)] The Preview element MUST be present in a command response if a BodyPartPreference element (section 2.2.2.11) in the request included a Preview element and the server can honor the request.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R253
            Site.CaptureRequirement(
                253,
                @"[In Preview (BodyPart)] The Preview element is an optional child element of the BodyPart element (section 2.2.2.10) that contains the Unicode plain text message or message part preview returned to the client.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R255
            Site.CaptureRequirement(
                255,
                @"[In Preview (BodyPart)] The Preview element in a response MUST contain no more than the number of characters specified in the request.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R2599
            Site.CaptureRequirement(
                2599,
                @"[In Preview (BodyPartPreference)] [The Preview element] specifies the maximum length of the Unicode plain text message or message part preview to be returned to the client.");
            #endregion
        }
        public void MSASAIRS_S01_TC07_BodyPartPreference_NotIncludedTruncationSize()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);

            DataStructures.Sync allContentItem = this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            #endregion

            #region Set BodyPartPreference element
            Request.BodyPartPreference[] bodyPartPreferenceAllOrNoneTrue = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    AllOrNone = true,
                    AllOrNoneSpecified = true
                }
            };

            Request.BodyPartPreference[] bodyPartPreferenceAllOrNoneFalse = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    AllOrNone = false,
                    AllOrNoneSpecified = true
                }
            };
            #endregion

            #region Verify Sync command related elements
            // Call Sync command with AllOrNone setting to TRUE
            DataStructures.Sync syncItemAllOrNoneTrue = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreferenceAllOrNoneTrue);

            this.VerifyBodyPartElements(syncItemAllOrNoneTrue.Email.BodyPart, true, false, false);

            // Call Sync command with AllOrNone setting to FALSE
            DataStructures.Sync syncItemAllOrNoneFalse = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreferenceAllOrNoneFalse);

            this.VerifyBodyPartElements(syncItemAllOrNoneFalse.Email.BodyPart, false, false, false);

            Site.Log.Add(
                LogEntryKind.Debug,
                "Entire content: {0}, content for AllOrNone TRUE: {1}, content for AllOrNone FALSE: {2}.",
                allContentItem.Email.BodyPart.Data,
                syncItemAllOrNoneTrue.Email.BodyPart.Data,
                syncItemAllOrNoneFalse.Email.BodyPart.Data);

            Site.Assert.IsTrue(
                allContentItem.Email.BodyPart.Data == syncItemAllOrNoneTrue.Email.BodyPart.Data && syncItemAllOrNoneTrue.Email.BodyPart.Data == syncItemAllOrNoneFalse.Email.BodyPart.Data,
                "Server should return the entire content for the request and same response no matter AllOrNone is true or false if the TruncationSize element is absent in Sync command request.");
            #endregion

            #region Verify ItemOperations command related elements
            // Call ItemOperations command with AllOrNone setting to true
            DataStructures.ItemOperations itemOperationsItemAllOrNoneTrue = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItemAllOrNoneTrue.ServerId, null, null, bodyPartPreferenceAllOrNoneTrue, null);

            this.VerifyBodyPartElements(itemOperationsItemAllOrNoneTrue.Email.BodyPart, true, false, false);

            // Call ItemOperations command with AllOrNone setting to false
            DataStructures.ItemOperations itemOperationsItemAllOrNoneFalse = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItemAllOrNoneTrue.ServerId, null, null, bodyPartPreferenceAllOrNoneFalse, null);

            this.VerifyBodyPartElements(itemOperationsItemAllOrNoneFalse.Email.BodyPart, false, false, false);

            Site.Log.Add(
                 LogEntryKind.Debug,
                 "Entire content: {0}, content for AllOrNone TRUE: {1}, content for AllOrNone FALSE: {2}.",
                 allContentItem.Email.BodyPart.Data,
                 itemOperationsItemAllOrNoneTrue.Email.BodyPart.Data,
                 itemOperationsItemAllOrNoneFalse.Email.BodyPart.Data);

            Site.Assert.IsTrue(
                allContentItem.Email.BodyPart.Data == itemOperationsItemAllOrNoneTrue.Email.BodyPart.Data && itemOperationsItemAllOrNoneTrue.Email.BodyPart.Data == itemOperationsItemAllOrNoneFalse.Email.BodyPart.Data,
                "Server should return the entire content for the request and same response no matter AllOrNone is true or false if the TruncationSize element is absent in ItemOperations command request.");
            #endregion

            #region Verify Search command related elements
            // Call Search command with AllOrNone setting to true
            DataStructures.Search searchItemAllNoneTrue = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItemAllOrNoneTrue.Email.ConversationId, null, bodyPartPreferenceAllOrNoneTrue);

            this.VerifyBodyPartElements(searchItemAllNoneTrue.Email.BodyPart, true, false, false);

            // Call Search command with AllOrNone setting to false
            DataStructures.Search searchItemAllNoneFalse = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItemAllOrNoneTrue.Email.ConversationId, null, bodyPartPreferenceAllOrNoneFalse);

            this.VerifyBodyPartElements(searchItemAllNoneFalse.Email.BodyPart, false, false, false);

            Site.Log.Add(
                 LogEntryKind.Debug,
                 "Entire content: {0}, content for AllOrNone TRUE: {1}, content for AllOrNone FALSE: {2}.",
                 allContentItem.Email.BodyPart.Data,
                 searchItemAllNoneTrue.Email.BodyPart.Data,
                 searchItemAllNoneFalse.Email.BodyPart.Data);

            Site.Assert.IsTrue(
                allContentItem.Email.BodyPart.Data == searchItemAllNoneTrue.Email.BodyPart.Data && searchItemAllNoneTrue.Email.BodyPart.Data == searchItemAllNoneFalse.Email.BodyPart.Data,
                "Server should return the entire content for the request and same response no matter AllOrNone is true or false if the TruncationSize element is absent in Search command request.");
            #endregion

            #region Verify requirements
            // According to above steps, requirements MS-ASAIRS_R294 and MS-ASAIRS_R400 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R294");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R294
            Site.CaptureRequirement(
                294,
                @"[In TruncationSize (BodyPartPreference)] If the TruncationSize element is absent, the entire content is used for the request.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R400
            Site.CaptureRequirement(
                400,
                @"[In AllOrNone (BodyPartPreference)]  If the TruncationSize element is not included, the server will return the same response no matter whether AllOrNone is true or false.");
            #endregion
        }
        public void MSASAIRS_S01_TC06_BodyPartPreference_NoAllOrNone_NonTruncatedContentReturned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);

            DataStructures.Sync allContentItem = this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            #endregion

            #region Set BodyPartPreference element
            Request.BodyPartPreference[] bodyPartPreference = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    TruncationSize = 100,
                    TruncationSizeSpecified = true
                }
            };
            #endregion

            #region Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreference);

            this.VerifyBodyPartElements(syncItem.Email.BodyPart, null, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R410
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                syncItem.Email.BodyPart.Data,
                410,
                @"[In AllOrNone (BodyPartPreference)] If the AllOrNone element is not included in the request, the nontruncated content is synchronized as if the value was set to 0 (FALSE).");
            #endregion

            #region Verify ItemOperations command related elements
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, bodyPartPreference, null);

            this.VerifyBodyPartElements(itemOperationsItem.Email.BodyPart, null, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R411
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                itemOperationsItem.Email.BodyPart.Data,
                411,
                @"[In AllOrNone (BodyPartPreference)] If the AllOrNone element is not included in the request, the nontruncated content is retrieved as if the value was set to 0 (FALSE).");
            #endregion

            #region Verify Search command related elements
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, bodyPartPreference);

            this.VerifyBodyPartElements(searchItem.Email.BodyPart, null, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R409
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                searchItem.Email.BodyPart.Data,
                409,
                @"[In AllOrNone (BodyPartPreference)] If the AllOrNone element is not included in the request, the nontruncated content is searched as if the value was set to 0 (FALSE).");
            #endregion

            #region Verify common requirements
            // According to above steps, requirement MS-ASAIRS_R283 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R283");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R283
            Site.CaptureRequirement(
                283,
                @"[In Truncated (BodyPart)] If the value [of the Truncated element] is FALSE, or there is no Truncated element, then the body of the item has not been truncated.");
            #endregion
        }
        /// <summary>
        /// Get the request of Search command.
        /// </summary>
        /// <param name="conversationId">The conversation for which to search.</param>
        /// <param name="bodyPartPreference">The BodyPartPreference in the Options element.</param>
        /// <param name="bodyPreference">The BodyPreference in the Options element.</param>
        /// <returns>A Search command request.</returns>
        internal static SearchRequest GetSearchRequest(string conversationId, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            SearchRequest request = new SearchRequest
            {
                RequestData =
                {
                    Items                                = new Request.SearchStore[]
                    {
                        new Request.SearchStore()
                        {
                            Name  = SearchName.Mailbox.ToString(),
                            Query = new Request.queryType()
                            {
                                Items                    = new object[]
                                {
                                    new Request.queryType()
                                    {
                                        Items            = new object[]
                                        {
                                            "Email",
                                            conversationId
                                        },
                                        ItemsElementName = new Request.ItemsChoiceType2[]
                                        {
                                            Request.ItemsChoiceType2.Class,
                                            Request.ItemsChoiceType2.ConversationId
                                        }
                                    }
                                },
                                ItemsElementName         = new Request.ItemsChoiceType2[]
                                {
                                    Request.ItemsChoiceType2.And
                                }
                            }
                        }
                    }
                }
            };

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

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

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

            items.Add(string.Empty);
            itemsElementName.Add(Request.ItemsChoiceType6.RebuildResults);
            items.Add("0-9");
            itemsElementName.Add(Request.ItemsChoiceType6.Range);
            items.Add(string.Empty);
            itemsElementName.Add(Request.ItemsChoiceType6.DeepTraversal);

            request.RequestData.Items[0].Options = new Request.Options1()
            {
                ItemsElementName = itemsElementName.ToArray(),
                Items            = items.ToArray()
            };

            return(request);
        }
        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>
        /// Find the specified email.
        /// </summary>
        /// <param name="subject">The subject of the email to find.</param>
        /// <param name="collectionId">The folder collectionId which needs to be synchronized.</param>
        /// <param name="isRetryNeeded">A Boolean value indicates whether need retry.</param>
        /// <param name="bodyPartPreference">The bodyPartPreference in the options element.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <returns>The found email object.</returns>
        protected Sync SyncEmail(string subject, string collectionId, bool isRetryNeeded, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            // Call initial Sync command.
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(collectionId);
            SyncStore   syncStore   = this.CONAdapter.Sync(syncRequest);

            // Find the specific email.
            syncRequest = TestSuiteHelper.GetSyncRequest(collectionId, syncStore.SyncKey, bodyPartPreference, bodyPreference, false);
            Sync syncResult = this.CONAdapter.SyncEmail(syncRequest, subject, isRetryNeeded);

            this.LatestSyncKey = syncStore.SyncKey;

            return(syncResult);
        }
        /// <summary>
        /// Call Search command to find a specified conversation.
        /// </summary>
        /// <param name="conversationId">The ConversationId of the items to search.</param>
        /// <param name="itemsCount">The count of the items expected to be found.</param>
        /// <param name="bodyPartPreference">The BodyPartPreference element.</param>
        /// <param name="bodyPreference">The BodyPreference element.</param>
        /// <returns>The SearchStore instance that contains the search result.</returns>
        protected SearchStore CallSearchCommand(string conversationId, int itemsCount, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference)
        {
            // Create Search command request.
            SearchRequest searchRequest = TestSuiteHelper.GetSearchRequest(conversationId, bodyPartPreference, bodyPreference);
            SearchStore   searchStore   = this.CONAdapter.Search(searchRequest, true, itemsCount);

            Site.Assert.AreEqual("1", searchStore.Status, "The Search operation should be success.");

            return(searchStore);
        }
        public void MSASAIRS_S01_TC02_BodyPartPreference_AllOrNoneTrue_AllContentNotReturned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);
            #endregion

            #region Set BodyPartPreference element
            Request.BodyPartPreference[] bodyPartPreference = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    TruncationSize = 2,
                    TruncationSizeSpecified = true,
                    AllOrNone = true,
                    AllOrNoneSpecified = true
                }
            };
            #endregion

            #region Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreference);

            this.VerifyBodyPartElements(syncItem.Email.BodyPart, true, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R376
            Site.CaptureRequirementIfIsNull(
                syncItem.Email.BodyPart.Data,
                376,
                @"[In AllOrNone] When the value is set to 1 (TRUE) and the content has been truncated, the content is not synchronized. ");
            #endregion

            #region Verify ItemOperations command related elements
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, bodyPartPreference, null);

            this.VerifyBodyPartElements(itemOperationsItem.Email.BodyPart, true, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R377
            Site.CaptureRequirementIfIsNull(
                itemOperationsItem.Email.BodyPart.Data,
                377,
                @"[In AllOrNone] When the value is set to 1 (TRUE) and the content has been truncated, the content is not retrieved. ");
            #endregion

            #region Verify Search command related elements
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, bodyPartPreference);

            this.VerifyBodyPartElements(searchItem.Email.BodyPart, true, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R375
            Site.CaptureRequirementIfIsNull(
                searchItem.Email.BodyPart.Data,
                375,
                @"[In AllOrNone] When the value is set to 1 (TRUE) and the content has been truncated, the content is not searched. ");
            #endregion

            #region Verify common requirements
            // According to above steps, requirement MS-ASAIRS_R63 can be covered directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R63");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R63
            Site.CaptureRequirement(
                63,
                @"[In AllOrNone (BodyPartPreference)] But, if the client also includes the AllOrNone element with a value of 1 (TRUE) along with the TruncationSize element, it is instructing the server not to return a truncated response for that type when the size (in bytes) of the available data exceeds the value of the TruncationSize element.");
            #endregion
        }
示例#12
0
        public void MSASCON_S01_TC07_Sync_MessagePart()
        {
            this.CheckActiveSyncVersionIsNot140();

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

            string subject             = Common.GenerateResourceName(Site, "Subject");
            string body                = Common.GenerateResourceName(Site, "Body");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);
            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, body);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            #region Call Sync command without BodyPreference or BodyPartPreference element.
            this.SwitchUser(this.User1Information, false);

            // Call Sync command without BodyPreference or BodyPartPreference element.
            Sync syncItem = this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, null);
            this.VerifyMessagePartWithoutPreference(syncItem.Email);

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

            // Verify MS-ASCON requirement: MS-ASCON_R237
            Site.CaptureRequirementIfIsNull(
                syncItem.Email.BodyPart,
                237,
                @"[In Sending a Message Part] The airsyncbase:BodyPart element is not present in the [Sync command] response if the client did not request the message part, as specified in section 3.1.4.10.");
            #endregion

            #region Call Sync command with only BodyPreference element.
            Request.BodyPreference bodyPreference = new Request.BodyPreference()
            {
                Type = 2,
            };

            syncItem = this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, bodyPreference);
            this.VerifyMessagePartWithBodyPreference(syncItem.Email);
            #endregion

            #region Call Sync command with only BodyPartPreference element.
            Request.BodyPartPreference bodyPartPreference = new Request.BodyPartPreference()
            {
                Type = 2,
            };

            // Get all the email BodyPart data.
            this.SyncEmail(subject, User1Information.InboxCollectionId, true, bodyPartPreference, null);
            XmlElement lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string     allData         = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);

            bodyPartPreference = new Request.BodyPartPreference()
            {
                Type                    = 2,
                TruncationSize          = 12,
                TruncationSizeSpecified = true,
            };

            syncItem        = this.SyncEmail(subject, User1Information.InboxCollectionId, true, bodyPartPreference, null);
            lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string truncatedData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);
            this.VerifyMessagePartWithBodyPartPreference(syncItem.Email, truncatedData, allData, (int)bodyPartPreference.TruncationSize);

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

            // Verify MS-ASCON requirement: MS-ASCON_R234
            Site.CaptureRequirementIfIsNotNull(
                syncItem.Email.BodyPart,
                234,
                @"[In Sending a Message Part] If the client Sync command request ([MS-ASCMD] section 2.2.1.21) [, Search command request ([MS-ASCMD] section 2.2.1.16) or ItemOperations command request 9([MS-ASCMD] section 2.2.1.10)] includes the airsyncbase:BodyPartPreference element (section 2.2.2.2), then the server uses the airsyncbase:BodyPart element (section 2.2.2.1) to encapsulate the message part in the response.");

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

            // A message part and its meta-data are encapsulated by BodyPart element in the Sync response, so this requirement can be captured.
            Site.CaptureRequirement(
                38,
                @"[In BodyPart] The airsyncbase:BodyPart element ([MS-ASAIRS] section 2.2.2.10) encapsulates a message part and its meta-data in a Sync command response ([MS-ASCMD] section 2.2.1.21) [, an ItemOperations command response ([MS-ASCMD] section 2.2.1.10) or a Search command response ([MS-ASCMD] section 2.2.1.16)].");
            #endregion

            #region Calls Sync command with both BodyPreference and BodyPartPreference elements.
            syncItem = this.SyncEmail(subject, User1Information.InboxCollectionId, true, bodyPartPreference, bodyPreference);
            this.VerifyMessagePartWithBothPreference(syncItem.Email);
            #endregion
        }
        /// <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 Sync command.
        /// </summary>
        /// <param name="collectionId">The collection id of the folder to sync.</param>
        /// <param name="syncKey">The SyncKey of the latest sync.</param>
        /// <param name="bodyPartPreference">The bodyPartPreference in the options element.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <param name="conversationMode">The value of ConversationMode element.</param>
        /// <returns>The request of Sync command.</returns>
        internal static SyncRequest GetSyncRequest(string collectionId, string syncKey, Request.BodyPartPreference bodyPartPreference, Request.BodyPreference bodyPreference, bool conversationMode)
        {
            // Create the Sync command request.
            Request.SyncCollection[] synCollections = new Request.SyncCollection[1];
            synCollections[0] = new Request.SyncCollection {
                SyncKey = syncKey, CollectionId = collectionId
            };

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

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

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

            if (conversationMode)
            {
                synCollections[0].ConversationMode          = true;
                synCollections[0].ConversationModeSpecified = true;
                synCollections[0].Options    = new Request.Options[1];
                synCollections[0].Options[0] = new Request.Options
                {
                    ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.FilterType },
                    Items            = new object[] { (byte)1 }
                };
            }

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

            return(Common.CreateSyncRequest(synCollections));
        }
        public void MSASCON_S05_TC03_Search_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 Search 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,
            };

            SearchRequest searchRequest = TestSuiteHelper.GetSearchRequest(syncItem.Email.ConversationId, bodyPartPreference, null);
            DataStructures.SearchStore searchStore = this.CONAdapter.Search(searchRequest, false, 0);
            this.VerifyMessagePartStatus164(byte.Parse(searchStore.StoreStatus));
            #endregion
        }
示例#16
0
        public void MSASCON_S01_TC08_Sync_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 sync command with BodyPartPreference element and set the Type element to 3
            this.SwitchUser(this.User1Information, false);

            // Check whether the mail has been received.
            this.SyncEmail(subject, User1Information.InboxCollectionId, true, null, null);

            Request.BodyPartPreference bodyPartPreference = new Request.BodyPartPreference()
            {
                Type = 3,
            };

            // Call initial Sync command.
            SyncRequest syncRequest = Common.CreateInitialSyncRequest(User1Information.InboxCollectionId);
            SyncStore syncStore = this.CONAdapter.Sync(syncRequest);

            syncRequest = TestSuiteHelper.GetSyncRequest(User1Information.InboxCollectionId, syncStore.SyncKey, bodyPartPreference, null, false);
            syncStore = this.CONAdapter.Sync(syncRequest);
            this.VerifyMessagePartStatus164(syncStore.Status);
            #endregion
        }
        public void MSASAIRS_S01_TC03_BodyPartPreference_AllOrNoneFalse_TruncatedContentReturned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);

            this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            XmlElement lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;
            string allData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);
            #endregion

            #region Set BodyPartPreference element
            Request.BodyPartPreference[] bodyPartPreference = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    TruncationSize = 8,
                    TruncationSizeSpecified = true,
                    AllOrNone = false,
                    AllOrNoneSpecified = true
                }
            };
            #endregion

            #region Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreference);
            lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;

            this.VerifyBodyPartElements(syncItem.Email.BodyPart, false, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R378
            Site.CaptureRequirementIfAreEqual<string>(
                TestSuiteHelper.TruncateData(allData, (int)bodyPartPreference[0].TruncationSize),
                TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject),
                378,
                @"[In AllOrNone] When the value is set to 0 (FALSE), the truncated is synchronized. ");
            #endregion

            #region Verify ItemOperations command related elements
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, bodyPartPreference, null);
            lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;

            this.VerifyBodyPartElements(itemOperationsItem.Email.BodyPart, false, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R379
            Site.CaptureRequirementIfAreEqual<string>(
                TestSuiteHelper.TruncateData(allData, (int)bodyPartPreference[0].TruncationSize),
                TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject),
                379,
                @"[In AllOrNone] When the value is set to 0 (FALSE), the truncated is retrieved. ");
            #endregion

            #region Verify Search command related elements
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, bodyPartPreference);
            lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;

            this.VerifyBodyPartElements(searchItem.Email.BodyPart, false, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R55
            Site.CaptureRequirementIfAreEqual<string>(
                TestSuiteHelper.TruncateData(allData, (int)bodyPartPreference[0].TruncationSize),
                TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject),
                55,
                @"[In AllOrNone] When the value is set to 0 (FALSE), the truncated is searched. ");
            #endregion

            #region Verify requirement
            // According to above steps, requirement MS-ASAIRS_R188 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R188");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R188
            Site.CaptureRequirement(
                188,
                @"[In Data (BodyPart)] If the Truncated element (section 2.2.2.39.2) is included in the response, then the data in the Data element is truncated.");
            #endregion
        }
        public void MSASAIRS_S01_TC04_BodyPartPreference_AllOrNoneFalse_NonTruncatedContentReturned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);

            DataStructures.Sync allContentItem = this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            #endregion

            #region Set BodyPartPreference element
            Request.BodyPartPreference[] bodyPartPreference = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    TruncationSize = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone = false,
                    AllOrNoneSpecified = true
                }
            };
            #endregion

            #region Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreference);

            this.VerifyBodyPartElements(syncItem.Email.BodyPart, false, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R381
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                syncItem.Email.BodyPart.Data,
                381,
                @"[In AllOrNone] When the value is set to 0 (FALSE), the nontruncated content is synchronized. ");
            #endregion

            #region Verify ItemOperations command related elements
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, bodyPartPreference, null);

            this.VerifyBodyPartElements(itemOperationsItem.Email.BodyPart, false, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R382
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                itemOperationsItem.Email.BodyPart.Data,
                382,
                @"[In AllOrNone] When the value is set to 0 (FALSE), the nontruncated content is retrieved. ");
            #endregion

            #region Verify Search command related elements
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, bodyPartPreference);

            this.VerifyBodyPartElements(searchItem.Email.BodyPart, false, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R380
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                searchItem.Email.BodyPart.Data,
                380,
                @"[In AllOrNone] When the value is set to 0 (FALSE), the nontruncated content is searched. ");
            #endregion
        }
        public void MSASAIRS_S01_TC05_BodyPartPreference_NoAllOrNone_TruncatedContentReturned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);

            this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            XmlElement lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;
            string allData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);
            #endregion

            #region Set BodyPreference element
            Request.BodyPartPreference[] bodyPartPreference = new Request.BodyPartPreference[]
            {
                new Request.BodyPartPreference()
                {
                    Type = 2,
                    TruncationSize = 8,
                    TruncationSizeSpecified = true
                }
            };
            #endregion

            #region Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreference);
            lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;

            this.VerifyBodyPartElements(syncItem.Email.BodyPart, null, true, true);

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

            // Verify MS-ASAIRS requirement: Verify MS-ASAIRS_R407
            Site.CaptureRequirementIfAreEqual<string>(
                TestSuiteHelper.TruncateData(allData, (int)bodyPartPreference[0].TruncationSize),
                TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject),
                407,
                @"[In AllOrNone (BodyPartPreference)] If the AllOrNone element is not included in the request, the truncated synchronized as if the value was set to 0 (FALSE).");
            #endregion

            #region Verify ItemOperations command related elements
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, bodyPartPreference, null);
            lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;

            this.VerifyBodyPartElements(itemOperationsItem.Email.BodyPart, null, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R408
            Site.CaptureRequirementIfAreEqual<string>(
                TestSuiteHelper.TruncateData(allData, (int)bodyPartPreference[0].TruncationSize),
                TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject),
                408,
                @"[In AllOrNone (BodyPartPreference)] If the AllOrNone element is not included in the request, the truncated retrieved as if the value was set to 0 (FALSE).");
            #endregion

            #region Verify Search command related elements
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, bodyPartPreference);
            lastRawResponse = (XmlElement)this.ASAIRSAdapter.LastRawResponseXml;

            this.VerifyBodyPartElements(searchItem.Email.BodyPart, null, true, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R392
            Site.CaptureRequirementIfAreEqual<string>(
                TestSuiteHelper.TruncateData(allData, (int)bodyPartPreference[0].TruncationSize),
                TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject),
                392,
                @"[In AllOrNone (BodyPartPreference)] If the AllOrNone element is not included in the request, the truncated searched as if the value was set to 0 (FALSE).");
            #endregion

            #region Verify common requirements
            // According to above steps, requirements MS-ASAIRS_R62 and MS-ASAIRS_R282 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R62");

            // Verify MS-ASAIRS requirement: Verify MS-ASAIRS_R62
            Site.CaptureRequirement(
                62,
                @"[In AllOrNone (BodyPartPreference)] [A client can include multiple BodyPartPreference elements in a command request with different values for the Type element] By default, the server returns the data truncated to the size requested by TruncationSize for the Type element that matches the native storage format of the item's Body element (section 2.2.2.9).");

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

            // Verify MS-ASAIRS requirement: Verify MS-ASAIRS_R282
            Site.CaptureRequirement(
                282,
                @"[In Truncated (BodyPart)] If the value [of the Truncated element] is TRUE, then the body of the item has been truncated.");
            #endregion
        }
        /// <summary>
        /// Get the non-truncated item data.
        /// </summary>
        /// <param name="subject">The subject of the item.</param>
        /// <param name="collectionId">The server id of the folder which contains the specified item.</param>
        /// <returns>The item with non-truncated data.</returns>
        protected DataStructures.Sync GetAllContentItem(string subject, string collectionId)
        {
            Request.BodyPartPreference[] bodyPartPreference = null;

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1")
                && !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.0"))
            {
                // Set the BodyPartPreference element to retrieve the BodyPart element in response
                bodyPartPreference = new Request.BodyPartPreference[]
                {
                    new Request.BodyPartPreference()
                    {
                        Type = 2
                    }
                };
            }

            // Set the BodyPreference element to retrieve the Body element in response
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 1
                }
            };

            // Get the item with specified subject
            DataStructures.Sync item = this.GetSyncResult(subject, collectionId, null, bodyPreference, bodyPartPreference);

            this.Site.Assert.IsNotNull(item.Email.Body, "The Body element should be included in Sync command response when the BodyPreference element is specified in Sync command request.");

            if (!Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1")
                && !Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.0"))
            {
                this.Site.Assert.IsNotNull(
                    item.Email.BodyPart,
                    "The BodyPart element should be included in Sync command response when the BodyPartPreference element is specified in Sync command request.");

                this.Site.Assert.AreEqual<byte>(
                    1,
                    item.Email.BodyPart.Status,
                    "The Status should be 1 to indicate the success of the Sync command response in returning Data element content given the BodyPartPreference element settings in the Sync command request.");
            }

            return item;
        }
        public void MSASAIRS_S01_TC01_BodyPartPreference_AllOrNoneTrue_AllContentReturned()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference 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.");
            Site.Assume.AreNotEqual<string>("14.0", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The BodyPartPreference element is not supported when the MS-ASProtocolVersion header is set to 14.0. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Send an html email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.HTML, subject, body);

            DataStructures.Sync allContentItem = this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            #endregion

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

            #region Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, bodyPartPreference);

            this.VerifyBodyPartElements(syncItem.Email.BodyPart, true, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R373
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                syncItem.Email.BodyPart.Data,
                373,
                @"[In AllOrNone] When the value [of the AllOrNone element] is set to 1 (TRUE) and the content has not been truncated, all of the content is synchronized.");
            #endregion

            #region Verify ItemOperations command related elements
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, null, bodyPartPreference, null);

            this.VerifyBodyPartElements(itemOperationsItem.Email.BodyPart, true, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R54
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                itemOperationsItem.Email.BodyPart.Data,
                54,
                @"[In AllOrNone] When the value [of the AllOrNone element] is set to 1 (TRUE) and the content has not been truncated, all of the content is retrieved.");
            #endregion

            #region Verify Search command related elements
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, itemOperationsItem.Email.ConversationId, null, bodyPartPreference);

            this.VerifyBodyPartElements(searchItem.Email.BodyPart, true, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R53
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.BodyPart.Data,
                searchItem.Email.BodyPart.Data,
                53,
                @"[In AllOrNone] When the value [of the AllOrNone element] is set to 1 (TRUE) and the content has not been truncated, all of the content is searched.");
            #endregion

            #region Verify common requirements
            // According to above steps, requirements MS-ASAIRS_R120 and MS-ASAIRS_R271 can be covered directly.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R120");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R120
            Site.CaptureRequirement(
                120,
                @"[In BodyPart] The BodyPart element MUST be included in a command response when the BodyPartPreference element (section 2.2.2.11) is specified in a request.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R271
            Site.CaptureRequirement(
                271,
                @"[In Status] [The value] 1 [of Status element] means Success.");
            #endregion
        }
        public void MSASCON_S03_TC08_ItemOperations_MessagePart()
        {
            this.CheckActiveSyncVersionIsNot140();

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

            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            string user1MailboxAddress = Common.GetMailAddress(User1Information.UserName, User1Information.UserDomain);
            string user2MailboxAddress = Common.GetMailAddress(User2Information.UserName, User2Information.UserDomain);
            this.CallSendMailCommand(user2MailboxAddress, user1MailboxAddress, subject, body);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.InboxCollectionId, subject, false);
            #endregion

            #region Call ItemOperations command without BodyPreference or BodyPartPreference element.
            this.SwitchUser(this.User1Information, false);

            // Get all of the email BodyPart data.
            BodyPartPreference bodyPartPreference = new BodyPartPreference()
            {
                Type = 2,
            };

            DataStructures.Sync syncItem = this.SyncEmail(subject, User1Information.InboxCollectionId, true, bodyPartPreference, null);
            XmlElement lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string allData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);

            DataStructures.Email email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, null, null);
            this.VerifyMessagePartWithoutPreference(email);

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

            // Verify MS-ASCON requirement: MS-ASCON_R340
            Site.CaptureRequirementIfIsNull(
                email.BodyPart,
                340,
                @"[In Sending a Message Part] The airsyncbase:BodyPart element is not present in the [ItemOperations command] response if the client did not request the message part, as specified in section 3.1.4.10.");
            #endregion

            #region Call ItemOperations command with only BodyPreference element.
            BodyPreference bodyPreference = new BodyPreference()
            {
                Type = 2,
            };

            email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, null, bodyPreference);
            this.VerifyMessagePartWithBodyPreference(email);
            #endregion

            #region Call ItemOperations command with only BodyPartPreference element.
            bodyPartPreference = new BodyPartPreference()
            {
                Type = 2,
                TruncationSize = 12,
                TruncationSizeSpecified = true,
            };

            email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, null);
            lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
            string truncatedData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);
            this.VerifyMessagePartWithBodyPartPreference(email, truncatedData, allData, (int)bodyPartPreference.TruncationSize);

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

            // Verify MS-ASCON requirement: MS-ASCON_R236
            Site.CaptureRequirementIfIsNotNull(
                email.BodyPart,
                236,
                @"[In Sending a Message Part] If the client [Sync command request ([MS-ASCMD] section 2.2.2.19.1), Search command request ([MS-ASCMD] section 2.2.2.14.1) or] ItemOperations command request 9([MS-ASCMD] section 2.2.2.8.2) includes the airsyncbase:BodyPartPreference element (section 2.2.2.2), then the server uses the airsyncbase:BodyPart element (section 2.2.2.1) to encapsulate the message part in the response.");

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

            // A message part and its meta-data are encapsulated by BodyPart element in the ItemOperation response, so this requirement can be captured.
            Site.CaptureRequirement(
                39,
                @"[In BodyPart] The airsyncbase:BodyPart element<1> ([MS-ASAIRS] section 2.2.2.5) encapsulates a message part and its meta-data in [a Sync command response ([MS-ASCMD] section 2.2.2.19),] an ItemOperations command response ([MS-ASCMD] section 2.2.2.8) [or a Search command response ([MS-ASCMD] section 2.2.2.14)].");
            #endregion

            #region Call ItemOperations command with both BodyPreference and BodyPartPreference elements.
            email = this.ItemOperationsFetch(User1Information.InboxCollectionId, syncItem.ServerId, bodyPartPreference, bodyPreference);
            this.VerifyMessagePartWithBothPreference(email);
            #endregion
        }
        public void MSASEMAIL_S01_TC20_ItemOperations_IncludedDataInResponse()
        {
            #region Call method SendMail to send an email.
            string emailSubject = Common.GenerateResourceName(Site, "subject");
            this.SendPlaintextEmail(emailSubject, string.Empty, string.Empty);
            #endregion

            #region Call ItemOperations command including BodyPreference element and BodyPartPreference element to fetch all the information about email using ServerId
            // Call method Sync to synchronize(add or change) the e-mail items with the server.
            Request.BodyPreference bodyPreference = new Request.BodyPreference
            {
                AllOrNone = true,
                AllOrNoneSpecified = true,
                TruncationSize = 5120,
                TruncationSizeSpecified = true,
                Type = 1
            };

            Request.BodyPartPreference bodyPartPreference = null;
            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.1"))
            {
                bodyPartPreference = new Request.BodyPartPreference
                {
                    AllOrNone = true,
                    AllOrNoneSpecified = true,
                    TruncationSize = 5120,
                    TruncationSizeSpecified = true,
                    Type = 2
                };
            }

            // Get the new added email item
            SyncStore syncChangeResult = this.GetSyncResult(emailSubject, this.User2Information.InboxCollectionId, bodyPreference);
            Sync item = TestSuiteHelper.GetSyncAddItem(syncChangeResult, emailSubject);

            // Fetch email from server
            ItemOperationsRequest itemOperationRequest = TestSuiteHelper.CreateItemOperationsFetchRequest(this.User2Information.InboxCollectionId, item.ServerId, bodyPreference, bodyPartPreference, null);
            ItemOperationsStore itemOperationResult = this.EMAILAdapter.ItemOperations(itemOperationRequest);
            #endregion

            #region Verify requirement
            // If the server responds with an ItemOperations response, then MS-ASEMAIL_R61 can be captured.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASEMAIL_R61");

            // Verify MS-ASEMAIL requirement: MS-ASEMAIL_R61
            Site.CaptureRequirementIfAreEqual<string>(
                "1",
                itemOperationResult.Status,
                61,
                @"[In ItemOperations Command Response] When a client uses an ItemOperations command request ([MS-ASCMD] section 2.2.2.9), as specified in section 3.1.5.1, to retrieve data from the server for one or more specific e-mail items, the server responds with an ItemOperations command response.");
            #endregion
        }