예제 #1
0
        public void MSASCNTC_S01_TC01_Sync_AddContact()
        {
            #region Call Sync command with Add element to add a contact with all Contact class elements to the server.
            string picture = "SmallPhoto.jpg";

            Dictionary<Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(picture);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());
            #endregion

            #region Call Sync command to synchronize the contact item that added in previous step
            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 1 };

            // Get the new added contact
            Sync newAddedItem = this.GetSyncAddResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, bodyPreference, null);

            Site.Assert.IsNull(
                newAddedItem.Contact.WeightedRank,
                "The Sync response should not contain WeightedRank since it is only returned in a recipient information cache response.");
            #endregion

            #region Verify requirements
            this.VerifyContactClassElements(contactProperties, newAddedItem.Contact);
            #endregion
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <returns>Returns the Sync request instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, bool?rightsManagementSupport)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

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

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object> {
                bodyPreference
            };

            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            if (rightsManagementSupport != null)
            {
                syncOptionItems.Add(rightsManagementSupport);
                syncOptionItemsName.Add(Request.ItemsChoiceType1.RightsManagementSupport);
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };
            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
예제 #3
0
        public void MSASCNTC_S03_TC01_Search_RetrieveContact()
        {
            #region Call Sync command with Add element to add a contact with all Contact class elements to the server
            string picture = "SmallPhoto.jpg";

            Dictionary<Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(picture);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());
            #endregion

            #region Call Search command to retrieve the contact item that added in previous step
            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 1 };

            Search searchItem = this.GetSearchResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, bodyPreference);
            #endregion

            #region Verify requirements
            this.VerifyContactClassElements(contactProperties, searchItem.Contact);
            #endregion
        }
        /// <summary>
        /// Creates a Sync change request by using the specified sync key, folder collection ID and change application data.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized.</param>
        /// <param name="data">Contains the data used to specify the Change element for Sync command.</param>
        /// <returns>Returns the SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, List<object> data)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                GetChanges = true,
                GetChangesSpecified = true,
                DeletesAsMoves = false,
                DeletesAsMovesSpecified = true,
                CollectionId = collectionId
            };

            Request.Options option = new Request.Options();
            Request.BodyPreference preference = new Request.BodyPreference
            {
                Type = 2,
                Preview = 0,
                PreviewSpecified = false
            };

            option.Items = new object[] { preference };
            option.ItemsElementName = new Request.ItemsChoiceType1[]
            {
                Request.ItemsChoiceType1.BodyPreference,
            };

            syncCollection.Options = new Request.Options[1];
            syncCollection.Options[0] = option;

            syncCollection.WindowSize = "512";

            if (data != null)
            {
                syncCollection.Commands = data.ToArray();
            }

            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
예제 #5
0
        /// <summary>
        /// Creates a Sync change request by using the specified sync key, folder collection ID and change application data.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized.</param>
        /// <param name="data">Contains the data used to specify the Change element for Sync command.</param>
        /// <returns>Returns the SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, List <object> data)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey                 = syncKey,
                GetChanges              = true,
                GetChangesSpecified     = true,
                DeletesAsMoves          = false,
                DeletesAsMovesSpecified = true,
                CollectionId            = collectionId
            };

            Request.Options        option     = new Request.Options();
            Request.BodyPreference preference = new Request.BodyPreference
            {
                Type             = 2,
                Preview          = 0,
                PreviewSpecified = false
            };

            option.Items            = new object[] { preference };
            option.ItemsElementName = new Request.ItemsChoiceType1[]
            {
                Request.ItemsChoiceType1.BodyPreference,
            };

            syncCollection.Options    = new Request.Options[1];
            syncCollection.Options[0] = option;

            syncCollection.WindowSize = "512";

            if (data != null)
            {
                syncCollection.Commands = data.ToArray();
            }

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
예제 #6
0
        public void MSASCNTC_S03_TC01_Search_RetrieveContact()
        {
            #region Call Sync command with Add element to add a contact with all Contact class elements to the server
            string picture = "SmallPhoto.jpg";

            Dictionary <Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(picture);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());
            #endregion

            #region Call Search command to retrieve the contact item that added in previous step
            Request.BodyPreference bodyPreference = new Request.BodyPreference {
                Type = 1
            };

            Search searchItem = this.GetSearchResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, bodyPreference);
            #endregion

            #region Verify requirements
            this.VerifyContactClassElements(contactProperties, searchItem.Contact);
            #endregion
        }
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command</param>
        /// <param name="rightsManagementSupport">A boolean value specifies whether the server will decompress and decrypt rights-managed email messages before sending them to the client or not</param>
        /// <returns>Returns the Sync request instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, bool? rightsManagementSupport)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

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

            Request.Options syncOptions = new Request.Options();
            List<object> syncOptionItems = new List<object> { bodyPreference };

            List<Request.ItemsChoiceType1> syncOptionItemsName = new List<Request.ItemsChoiceType1>
            {
                Request.ItemsChoiceType1.BodyPreference
            };

            if (rightsManagementSupport != null)
            {
                syncOptionItems.Add(rightsManagementSupport);
                syncOptionItemsName.Add(Request.ItemsChoiceType1.RightsManagementSupport);
            }

            syncOptions.Items = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options = new Request.Options[] { syncOptions };
            return Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection });
        }
        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
        }
예제 #9
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);
        }
        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
        }
예제 #11
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);
        }
        public void MSASAIRS_S02_TC01_BodyPreference_AllOrNoneTrue_AllContentReturned()
        {
            #region Send a plain text email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

            DataStructures.Sync allContentItem = this.GetAllContentItem(subject, this.User2Information.InboxCollectionId);
            #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 Verify Sync command related elements
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, bodyPreference, null);

            this.VerifyBodyElements(syncItem.Email.Body, 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.Body.Data,
                syncItem.Email.Body.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.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R304
            Site.CaptureRequirementIfAreEqual<byte>(
                1,
                syncItem.Email.Body.Type,
                304,
                @"[In Type] [The value] 1 [of Type element] means Plain text.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R237
            Site.CaptureRequirementIfAreEqual<string>(
                "1",
                syncItem.Email.NativeBodyType.ToString(),
                237,
                @"[In NativeBodyType] [The value] 1 represents Plain text.");
            #endregion

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

            this.VerifyBodyElements(itemOperationsItem.Email.Body, 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.Body.Data,
                itemOperationsItem.Email.Body.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, bodyPreference, null);

            this.VerifyBodyElements(searchItem.Email.Body, 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.Body.Data,
                searchItem.Email.Body.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
        }
        public void MSASAIRS_S02_TC02_BodyPreference_AllOrNoneTrue_AllContentNotReturned()
        {
            #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 = 2,
                    TruncationSizeSpecified = true,
                    AllOrNone = true,
                    AllOrNoneSpecified = true
                }
            };
            #endregion

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

            this.VerifyBodyElements(syncItem.Email.Body, 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.Body.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, bodyPreference, null, null);

            this.VerifyBodyElements(itemOperationsItem.Email.Body, 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.Body.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, bodyPreference, null);

            this.VerifyBodyElements(searchItem.Email.Body, 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.Body.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_R78 can be covered directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R78");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R78
            Site.CaptureRequirement(
                78,
                @"[In AllOrNone (BodyPreference)] 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
        }
예제 #14
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
        }
예제 #15
0
        public void MSASAIRS_S04_TC01_Sync_Status4()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

            // Make sure the email has reached the inbox folder of the recipient
            this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            #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 Sync command with incorrect order of child elements of BodyPreference
            SyncRequest request = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, null, bodyPreference, null);
            XmlDocument doc     = new XmlDocument();
            doc.LoadXml(request.GetRequestDataSerializedXML());
            XmlNode bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");

            // Put the first node to the end.
            XmlNode temp = bodyPreferenceNode.ChildNodes[0];
            bodyPreferenceNode.RemoveChild(temp);
            bodyPreferenceNode.AppendChild(temp);

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

            string status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R348
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                348,
                @"[In Validating XML] If the child elements of BodyPreference (section 2.2.2.12) are not in the correct order, the server returns protocol status error 4 (for a Sync command).");
            #endregion

            #region Call Sync command with a non-boolean value of AllOrNone element
            doc.LoadXml(request.GetRequestDataSerializedXML());
            XmlNode allOrNoneNode = doc.SelectSingleNode("//*[name()='AllOrNone']");

            // Set the AllOrNone element value to non-boolean.
            allOrNoneNode.InnerText = "a";

            response = this.ASAIRSAdapter.Sync(doc.OuterXml);

            status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R350
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                350,
                @"[In Validating XML] If the AllOrNone (section 2.2.2.3.2) element is not of type boolean, the server returns protocol status error 4 (for Sync command).");
            #endregion

            #region Call Sync command with multiple AllOrNone elements in a single BodyPreference element
            doc.LoadXml(request.GetRequestDataSerializedXML());
            bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");
            allOrNoneNode      = doc.SelectSingleNode("//*[name()='AllOrNone']");
            temp = allOrNoneNode.Clone();
            bodyPreferenceNode.AppendChild(temp);

            response = this.ASAIRSAdapter.Sync(doc.OuterXml);

            status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R351
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                351,
                @"[In Validating XML] If multiple AllOrNone elements are in a single BodyPreference element, the server returns protocol status error 4 (for Sync command).");
            #endregion
        }
예제 #16
0
        /// <summary>
        /// Create one search request with MIMESupport and related element
        /// </summary>
        /// <param name="keyWord">Search keyword</param>
        /// <param name="mimeSupportValue">MIMESupport element value</param>
        /// <returns>The search request</returns>
        private SearchRequest CreateSearchRequestWithMimeSupport(string keyWord, byte mimeSupportValue)
        {
            // Create search Option element
            Request.Options1 searchOption = new Request.Options1();
            searchOption.ItemsElementName = new Request.ItemsChoiceType6[] { Request.ItemsChoiceType6.RebuildResults, Request.ItemsChoiceType6.DeepTraversal, Request.ItemsChoiceType6.MIMESupport, Request.ItemsChoiceType6.BodyPreference };

            // Set bodyPrference element value
            Request.BodyPreference bodyPreference = new Request.BodyPreference();
            bodyPreference.Type = 4;
            bodyPreference.TruncationSize = 100;
            bodyPreference.TruncationSizeSpecified = true;

            // Set search Option element value
            searchOption.Items = new object[] { string.Empty, string.Empty, mimeSupportValue, bodyPreference };

            // Create search Query element
            Request.queryType searchQuery = new Request.queryType();
            searchQuery.ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And };
            searchQuery.Items = new Request.queryType[] { new Request.queryType() };
            ((Request.queryType)searchQuery.Items[0]).ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.Class, Request.ItemsChoiceType2.CollectionId, Request.ItemsChoiceType2.FreeText };
            ((Request.queryType)searchQuery.Items[0]).Items = new object[] { "Email", this.User1Information.InboxCollectionId, keyWord };

            SearchRequest searchRequest = this.CreateDefaultSearchRequest();
            searchRequest.RequestData.Items[0].Options = searchOption;
            searchRequest.RequestData.Items[0].Query = searchQuery;
            return searchRequest;
        }
예제 #17
0
        /// <summary>
        /// Builds a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// </summary>
        /// <param name="syncKey">Specifies the sync key obtained from the last sync response.</param>
        /// <param name="collectionId">Specifies the server ID of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            // Sets Getchanges only if SyncKey != 0 since fail response is returned when the SyncKey element value is 0.
            if (syncKey != "0")
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "512";

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object>();
            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        public void MSASCMD_S08_TC08_ItemOperations_Fetch_MIMESupport()
        {
            #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);
            #endregion

            #region Call method ItemOperations which contains the Fetch element with inline method and MIMESupport setting to 0.
            Request.ItemOperationsFetchOptions options = new Request.ItemOperationsFetchOptions();
            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 4 };

            // Set the value of MIMESupport element to 0, which indicates never to send MIME data.
            options.Items = new object[] { (byte)0, bodyPreference };
            options.ItemsElementName = new Request.ItemsChoiceType5[] { Request.ItemsChoiceType5.MIMESupport, Request.ItemsChoiceType5.BodyPreference };
            ItemOperationsRequest itemOperationsRequest = CreateItemOperationsRequestWithFetchElement(this.User1Information.InboxCollectionId, SearchName.Mailbox.ToString(), serverId, options);
            ItemOperationsResponse itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            Response.Body body = this.GetBodyElement(itemOperationsResponse);
            Site.Assert.IsNull(body.Data, "There should be no MIME data returned when MIMESupport setting to 0.");
            #endregion

            #region Call method ItemOperations which contains the Fetch element with inline method and MIMESupport setting to 1.

            // Set the value of MIMESupport element to 1, which indicates to send MIME data for S/MIME messages only, and send regular body for all other messages.
            // In this case, the response of this step contains no MIME data.
            options.Items = new object[] { (byte)1, bodyPreference };
            itemOperationsRequest = CreateItemOperationsRequestWithFetchElement(this.User1Information.InboxCollectionId, SearchName.Mailbox.ToString(), serverId, options);
            itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            body = this.GetBodyElement(itemOperationsResponse);
            Site.Assert.IsNull(body.Data, "There should be no MIME data returned for normal message when MIMESupport setting to 1.");
            #endregion

            #region Call method ItemOperations which contains the Fetch element with inline method and MIMESupport setting to 2.

            // Set the value of MIMESupport element to 2, which indicates to send MIME data for all messages.
            options.Items = new object[] { (byte)2, bodyPreference };
            itemOperationsRequest = CreateItemOperationsRequestWithFetchElement(this.User1Information.InboxCollectionId, SearchName.Mailbox.ToString(), serverId, options);
            itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.Inline);
            body = this.GetBodyElement(itemOperationsResponse);
            Site.Assert.IsNotNull(body.Data, "There should be MIME data returned for normal message when MIMESupport setting to 2.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3366
            Site.CaptureRequirementIfAreEqual<byte>(
                4,
                body.Type,
                3366,
                @"[In MIMESupport(ItemOperations)] The airsyncbase:Type element ([MS-ASAIRS] section 2.2.2.22.1) with a value of 4 to inform the device that the data is a MIME BLOB.");

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

            Site.Assert.IsTrue(body.EstimatedDataSizeSpecified, "The EstimatedDataSize element should be specified in response when MIMESupport setting to 2.");
            XmlElement lastRawResponse = (XmlElement)this.CMDAdapter.LastRawResponseXml;
            string data = GetElementInnerText(lastRawResponse, "Body", "Data", subject);

            // Verify MS-ASCMD requirement: MS-ASCMD_R3367
            Site.CaptureRequirementIfAreEqual<uint>(
                (uint)data.Length,
                body.EstimatedDataSize,
                3367,
                @"[In MIMESupport(ItemOperations)] The airsyncbase:EstimatedDataSize element ([MS-ASAIRS] section 2.2.2.12.2) to specify the rough total size of the data.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3368
            // If response Body element contains data element, that means response contains full MIME BLOB data then MS-ASCMD_R3368 is verified.
            Site.CaptureRequirementIfIsNotNull(
                body.Data,
                3368,
                @"[In MIMESupport(ItemOperations)] The airsyncbase:Data element ([MS-ASAIRS] section 2.2.2.10.1) that contains the full MIME BLOB.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R3360
            // This requirement can be capture after above steps.
            Site.CaptureRequirement(
                3360,
                @"[In MIMESupport(ItemOperations)] [To support fetching of the full S/MIME message, the Fetch (section 2.2.3.63.1) request MUST include] The airsync:MIMESupport element (section 2.2.3.100.3) to indicate to the server to return MIME for S/MIME-only messages, all messages, or no messages.");
            #endregion

            #region Call method SendStringRequest to call ItemOperations command without specifying delivery method and with MIMESupport setting to 2.
            string request = itemOperationsRequest.GetRequestDataSerializedXML();
            SendStringResponse sendStringResponse = this.CMDAdapter.SendStringRequest(CommandName.ItemOperations, null, request);
            Site.Assert.IsNotNull(sendStringResponse.ResponseDataXML, "The XML data in response should not be null.");
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sendStringResponse.ResponseDataXML);
            XmlElement xmlElement = (XmlElement)doc.DocumentElement;
            string defaultData = GetElementInnerText(xmlElement, "Body", "Data", subject);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5503
            // If the data gotten by ItemOperations command with inline method is equal to the data got by ItemOperations without specifying delivery method, this requirement can be captured.
            Site.CaptureRequirementIfAreEqual<string>(
                defaultData,
                data,
                5503,
                @"[In Delivery of Content Requested by Fetch] The inline method is the default method for ItemOperations responses.");
            #endregion

            #region Call method ItemOperations which contains the Fetch element with MultiPart method and MIMESupport setting to 2.
            itemOperationsResponse = this.CMDAdapter.ItemOperations(itemOperationsRequest, DeliveryMethodForFetch.MultiPart);
            body = this.GetBodyElement(itemOperationsResponse);

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

            // When the item being fetched is located in a mailbox, server returns the Part element as a child of the airsyncbase:Body.
            // Verify MS-ASCMD requirement: MS-ASCMD_R5366
            Site.CaptureRequirementIfIsNotNull(
                body.Part,
                5366,
                @"[In Part] It [Part element] is a child of the airsyncbase:Body element if the item being fetched is located in a mailbox.");
            #endregion
        }
예제 #19
0
 /// <summary>
 /// Synchronize the changes from last synchronization in specific folder.
 /// </summary>
 /// <param name="syncKey">The sync key.</param>
 /// <param name="collectionID">Folder's collectionID.</param>
 /// <param name="isResyncNeeded">A boolean value indicate whether need to re-sync when the response contains MoreAvailable.</param>
 /// <returns>Sync response from the server.</returns>
 protected SyncResponse SyncChanges(string syncKey, string collectionID, bool isResyncNeeded = true)
 {
     SyncRequest syncRequest = TestSuiteBase.CreateEmptySyncRequest(collectionID);
     syncRequest.RequestData.Collections[0].SyncKey = syncKey;
     Request.Options options = new Request.Options();
     Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 1 };
     options.Items = new object[] { bodyPreference };
     options.ItemsElementName = new Request.ItemsChoiceType1[] { Request.ItemsChoiceType1.BodyPreference };
     syncRequest.RequestData.Collections[0].Options = new Request.Options[] { options };
     syncRequest.RequestData.Collections[0].GetChanges = true;
     syncRequest.RequestData.Collections[0].GetChangesSpecified = true;
     SyncResponse syncResponse = this.Sync(syncRequest, isResyncNeeded);
     return syncResponse;
 }
        public void MSASAIRS_S02_TC13_NativeBodyTypeAndType_HTML()
        {
            #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 BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 2
                }
            };

            Request.BodyPreference[] bodyPreferenceWithType4 = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 4
                }
            };
            #endregion

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

            this.VerifyType(syncItem.Email, bodyPreference[0].Type);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R238
            Site.CaptureRequirementIfAreEqual<byte?>(
                2,
                syncItem.Email.NativeBodyType,
                238,
                @"[In NativeBodyType] [The value] 2 represents HTML.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R2411
            Site.CaptureRequirement(
                2411,
                @"[In NativeBodyType]  The NativeBodyType and Type elements have the same value if the server has not modified the format of the body to match the client's request.");
            #endregion

            #region Verify ItemOperations command
            DataStructures.ItemOperations itemOperationsItem = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, bodyPreference, null, DeliveryMethodForFetch.Inline);

            this.VerifyType(itemOperationsItem.Email, bodyPreference[0].Type);
            #endregion

            #region Verify Search command
            DataStructures.Search searchItem = this.GetSearchResult(subject, this.User2Information.InboxCollectionId, null, bodyPreference, null);

            this.VerifyType(searchItem.Email, bodyPreference[0].Type);
            #endregion

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R305
            Site.CaptureRequirement(
                305,
                @"[In Type] [The value] 2 [of Type element] means HTML.");
            #endregion

            #region Verify Sync command when setting Type to 4
            DataStructures.Sync syncItemWithType4 = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, bodyPreferenceWithType4, null);

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

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R307
            Site.CaptureRequirementIfAreEqual<byte>(
                4,
                syncItemWithType4.Email.Body.Type,
                307,
                @"[In Type] [The value] 4 [of Type element] means MIME.");

            Site.Assert.AreEqual<byte?>(
                2,
                syncItemWithType4.Email.NativeBodyType,
                "The NativeBodyType value should be 2.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R2412
            Site.CaptureRequirementIfAreNotEqual<byte?>(
                syncItemWithType4.Email.Body.Type,
                syncItemWithType4.Email.NativeBodyType,
                2412,
                @"[In NativeBodyType]  The NativeBodyType and Type elements have different values if the server has modified the format of the body to match the client's request.");
            #endregion
        }
예제 #21
0
        public void MSASAIRS_S04_TC06_MultipleBodyPreferenceHaveSameTypeValue()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body    = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

            // Make sure the email has reached the inbox folder of the recipient
            this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            #endregion

            #region Set two BodyPreference elements with same type value
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type                    = 1,
                    TruncationSize          = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone               = true,
                    AllOrNoneSpecified      = true
                },

                new Request.BodyPreference()
                {
                    Type                    = 1,
                    TruncationSize          = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone               = true,
                    AllOrNoneSpecified      = true
                }
            };
            #endregion

            #region Verify multiple BodyPreference elements with same type value in Sync for related requirements
            SyncRequest request = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, null, bodyPreference, null);

            if (Common.IsRequirementEnabled(10015, this.Site))
            {
                try
                {
                    this.ASAIRSAdapter.Sync(request);

                    Site.Assert.Fail("The server should return an HTTP error 500 if multiple BodyPreference elements are present with the same value in the Type child element.");
                }
                catch (WebException exception)
                {
                    int errorCode = ((HttpWebResponse)exception.Response).StatusCode.GetHashCode();

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

                    // Verify MS-ASAIRS requirement: MS-ASAIRS_R10015
                    Site.CaptureRequirementIfAreEqual <int>(
                        500,
                        errorCode,
                        10015,
                        @"[In Appendix B: Product Behavior] Implementation does return an HTTP error 500 instead of a Status value of 4 when multiple BodyPreference elements are present with the same value in the Type child element. (<1> Section 3.2.5.1:  Exchange 2007 SP1 returns an HTTP error 500 instead of a Status value of 4 when multiple BodyPreference elements are present with the same value in the Type child element.)");
                }
            }

            if (Common.IsRequirementEnabled(10016, this.Site))
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(request.GetRequestDataSerializedXML());

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

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

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10016
                Site.CaptureRequirementIfAreEqual(
                    "4",
                    status,
                    10016,
                    @"[In Appendix B: Product Behavior] Implementation does return 4 (for Sync command) if multiple BodyPreference elements are present with the same value in the Type child element. (Exchange Server 2010 and above follow this behavior.)");
            }
            #endregion
        }
        public void MSASAIRS_S02_TC04_BodyPreference_AllOrNoneFalse_NonTruncatedContentReturned()
        {
            #region Send a plain text email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

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

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 1,
                    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, bodyPreference, null);

            this.VerifyBodyElements(syncItem.Email.Body, 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.Body.Data,
                syncItem.Email.Body.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, bodyPreference, null, null);

            this.VerifyBodyElements(itemOperationsItem.Email.Body, 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.Body.Data,
                itemOperationsItem.Email.Body.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, bodyPreference, null);

            this.VerifyBodyElements(searchItem.Email.Body, 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.Body.Data,
                searchItem.Email.Body.Data,
                380,
                @"[In AllOrNone] When the value is set to 0 (FALSE), the nontruncated content is searched. ");
            #endregion
        }
        public void MSASCMD_S20_TC01_ValidateCert_Success()
        {
            #region Switch to User9 mail account, the inbox had received a S/MIME mail.

            this.SwitchUser(this.User9Information);

            #endregion

            #region Call method Sync to synchronize changes of Inbox folder in User9's mailbox between the client and the server, and get the body content of the email item.

            string emailSubject = Common.GetConfigurationPropertyValue("MIMEMailSubject", this.Site);

            Request.BodyPreference bodyPreference = new Request.BodyPreference
            {
                AllOrNone               = false,
                AllOrNoneSpecified      = true,
                TruncationSize          = 4294967295,
                TruncationSizeSpecified = true,
                Type = 4
            };

            Request.Options option = new Request.Options
            {
                Items            = new object[] { (byte)2, bodyPreference, (byte)8 },
                ItemsElementName = new Request.ItemsChoiceType1[]
                {
                    Request.ItemsChoiceType1.MIMESupport,
                    Request.ItemsChoiceType1.BodyPreference, Request.ItemsChoiceType1.MIMETruncation
                }
            };

            SyncResponse  syncResponse = this.CheckEmail(this.User9Information.InboxCollectionId, emailSubject, new Request.Options[] { option });
            Response.Body mailBody     = null;
            Response.SyncCollectionsCollectionCommandsAddApplicationData applicationData = TestSuiteBase.GetAddApplicationData(syncResponse, Response.ItemsChoiceType8.Subject1, emailSubject);
            for (int i = 0; i < applicationData.ItemsElementName.Length; i++)
            {
                if (applicationData.ItemsElementName[i] == Response.ItemsChoiceType8.Body)
                {
                    mailBody = applicationData.Items[i] as Response.Body;
                    break;
                }
            }

            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");

            string specifiedString = "MIME-Version: 1.0";
            string body            = mailBody.Data.Substring(
                mailBody.Data.IndexOf(specifiedString, StringComparison.CurrentCultureIgnoreCase) + specifiedString.Length);
            body = body.Replace("\r", string.Empty);
            body = body.Replace("\n", string.Empty);

            Request.ValidateCert validateCert = new Request.ValidateCert
            {
                CheckCrl     = "1",
                Certificates = new byte[][] { System.Text.Encoding.Default.GetBytes(body) }
            };

            ValidateCertRequest validateRequest = new ValidateCertRequest {
                RequestData = validateCert
            };

            ValidateCertResponse validateResponse = this.CMDAdapter.ValidateCert(validateRequest);

            XmlNodeList status = this.GetValidateCertStatusCode(validateResponse);

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R4474
            Site.CaptureRequirementIfAreEqual <string>(
                "1",
                status[0].InnerText,
                4474,
                @"[In Status(ValidateCert)] [When the scope is Global], [the cause of the status value 1 is] Server successfully completed command.");

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

            // Verify MS-ASCMD requirement: MS-ASCMD_R5387
            Site.CaptureRequirementIfAreEqual <string>(
                "1",
                status[0].InnerText,
                5387,
                @"[In Status(ValidateCert)] A value of 1 indicates success.");
            #endregion
        }
        public void MSASAIRS_S02_TC07_BodyPreference_NotIncludedTruncationSize()
        {
            #region Send a plain text email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

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

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreferenceAllOrNoneTrue = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 1,
                    AllOrNone = true,
                    AllOrNoneSpecified = true
                }
            };

            Request.BodyPreference[] bodyPreferenceAllOrNoneFalse = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 1,
                    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, bodyPreferenceAllOrNoneTrue, null);

            this.VerifyBodyElements(syncItemAllOrNoneTrue.Email.Body, true, false, false);

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

            this.VerifyBodyElements(syncItemAllOrNoneFalse.Email.Body, false, false, false);

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

            Site.Assert.IsTrue(
                allContentItem.Email.Body.Data == syncItemAllOrNoneTrue.Email.Body.Data && syncItemAllOrNoneTrue.Email.Body.Data == syncItemAllOrNoneFalse.Email.Body.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, bodyPreferenceAllOrNoneTrue, null, null);

            this.VerifyBodyElements(itemOperationsItemAllOrNoneTrue.Email.Body, true, false, false);

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

            this.VerifyBodyElements(itemOperationsItemAllOrNoneFalse.Email.Body, false, false, false);

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

            Site.Assert.IsTrue(
                allContentItem.Email.Body.Data == itemOperationsItemAllOrNoneTrue.Email.Body.Data && itemOperationsItemAllOrNoneTrue.Email.Body.Data == itemOperationsItemAllOrNoneFalse.Email.Body.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, bodyPreferenceAllOrNoneTrue, null);

            this.VerifyBodyElements(searchItemAllNoneTrue.Email.Body, true, false, false);

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

            this.VerifyBodyElements(searchItemAllNoneFalse.Email.Body, false, false, false);

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

            Site.Assert.IsTrue(
                allContentItem.Email.Body.Data == searchItemAllNoneTrue.Email.Body.Data && searchItemAllNoneTrue.Email.Body.Data == searchItemAllNoneFalse.Email.Body.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 common requirements
            // According to above steps, requirements MS-ASAIRS_R300 and MS-ASAIRS_R401 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R300");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R300
            Site.CaptureRequirement(
                300,
                @"[In TruncationSize (BodyPreference)] 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_R401");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R401
            Site.CaptureRequirement(
                401,
                @"[In AllOrNone (BodyPreference)]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 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.");
        }
예제 #26
0
        /// <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);
        }
예제 #27
0
        /// <summary>
        /// Create a generic Sync request without command references by using the specified sync key, folder collectionId and body preference option.
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last Sync response.</param>
        /// <param name="collectionId">Specify the serverId of the folder to be synchronized.</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body.</param>
        /// <returns>The SyncRequest instance.</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = CreateSyncCollection(syncKey, collectionId);

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object>();
            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);

                // when body format is mime (Refer to  [MS-ASAIRS] 2.2.2.22 Type)
                if (bodyPreference.Type == 0x4)
                {
                    syncOptionItemsName.Add(Request.ItemsChoiceType1.MIMESupport);

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

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
예제 #28
0
        /// <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);
        }
예제 #29
0
        /// <summary>
        /// Create a Search request.
        /// </summary>
        /// <param name="query">The query string.</param>
        /// <param name="collectionId">The collection id of searched folder.</param>
        /// <param name="bodyPreference">The bodyPreference in the options element.</param>
        /// <returns>A Search command request.</returns>
        internal static SearchRequest CreateSearchRequest(string query, string collectionId, 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[]
                                        {
                                            collectionId,
                                            query
                                        },
                                        ItemsElementName = new Request.ItemsChoiceType2[]
                                        {
                                            Request.ItemsChoiceType2.CollectionId,
                                            Request.ItemsChoiceType2.FreeText
                                        }
                                    }
                                },
                                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);

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

            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);
        }
예제 #30
0
        /// <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);
        }
예제 #31
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);
        }
        /// <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;
        }
예제 #33
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>
        /// Call Sync command to fetch the change of the notes from previous syncKey
        /// </summary>
        /// <param name="syncKey">The sync key</param>
        /// <param name="bodyType">The type of the body</param>
        /// <returns>Return change result</returns>
        protected SyncStore SyncChanges(string syncKey, byte bodyType)
        {
            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = bodyType };

            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(syncKey, this.UserInformation.NotesCollectionId, bodyPreference);
            SyncStore syncResult = this.NOTEAdapter.Sync(syncRequest, true);

            return syncResult;
        }
        public void MSASAIRS_S04_TC01_Sync_Status4()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

            // Make sure the email has reached the inbox folder of the recipient
            this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            #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 Sync command with incorrect order of child elements of BodyPreference
            SyncRequest request = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, null, bodyPreference, null);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(request.GetRequestDataSerializedXML());
            XmlNode bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");

            // Put the first node to the end.
            XmlNode temp = bodyPreferenceNode.ChildNodes[0];
            bodyPreferenceNode.RemoveChild(temp);
            bodyPreferenceNode.AppendChild(temp);

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

            string status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R348
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                348,
                @"[In Validating XML] If the child elements of BodyPreference (section 2.2.2.12) are not in the correct order, the server returns protocol status error 4 (for a Sync command).");
            #endregion

            #region Call Sync command with a non-boolean value of AllOrNone element
            doc.LoadXml(request.GetRequestDataSerializedXML());
            XmlNode allOrNoneNode = doc.SelectSingleNode("//*[name()='AllOrNone']");

            // Set the AllOrNone element value to non-boolean.
            allOrNoneNode.InnerText = "a";

            response = this.ASAIRSAdapter.Sync(doc.OuterXml);

            status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R350
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                350,
                @"[In Validating XML] If the AllOrNone (section 2.2.2.3.2) element is not of type boolean, the server returns protocol status error 4 (for Sync command).");
            #endregion

            #region Call Sync command with multiple AllOrNone elements in a single BodyPreference element
            doc.LoadXml(request.GetRequestDataSerializedXML());
            bodyPreferenceNode = doc.SelectSingleNode("//*[name()='BodyPreference']");
            allOrNoneNode = doc.SelectSingleNode("//*[name()='AllOrNone']");
            temp = allOrNoneNode.Clone();
            bodyPreferenceNode.AppendChild(temp);

            response = this.ASAIRSAdapter.Sync(doc.OuterXml);

            status = this.GetStatusCodeFromXPath(response, "/a:Sync/a:Status");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R351
            Site.CaptureRequirementIfAreEqual(
                "4",
                status,
                351,
                @"[In Validating XML] If multiple AllOrNone elements are in a single BodyPreference element, the server returns protocol status error 4 (for Sync command).");
            #endregion
        }
        public void MSASAIRS_S02_TC12_NativeBodyTypeAndType_RTF()
        {
            #region Send a mail with an embedded OLE object
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.AttachOLE, subject, body);
            #endregion

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 3
                }
            };
            #endregion

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

            this.VerifyType(syncItem.Email, bodyPreference[0].Type);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R239
            Site.CaptureRequirementIfAreEqual<byte?>(
                3,
                syncItem.Email.NativeBodyType,
                239,
                @"[In NativeBodyType] [The value] 3 represents RTF.");
            #endregion

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

            this.VerifyType(itemOperationsItem.Email, bodyPreference[0].Type);
            #endregion

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

            this.VerifyType(searchItem.Email, bodyPreference[0].Type);

            try
            {
                Convert.FromBase64String(searchItem.Email.Body.Data);

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R179
                Site.CaptureRequirement(
                    179,
                    @"[In Data (Body)] If the value of the Type element is 3 (RTF), the value of the Data element is encoded using base64 encoding.");
            }
            catch (FormatException)
            {
                Site.Assert.Fail("The value of Data element should be encoded using base64 encoding.");
            }
            #endregion

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R306
            Site.CaptureRequirement(
                306,
                @"[In Type] [The value] 3 [of Type element] means RTF.");
            #endregion
        }
        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
        }
        public void MSASAIRS_S02_TC14_ItemOperations_Part()
        {
            #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[] bodyPreferences = new Request.BodyPreference[]
            {
                new Request.BodyPreference
                {
                    Type = 4
                }
            };
            #endregion

            #region Synchronize the email item
            DataStructures.Sync syncItem = this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            #endregion

            #region Call ItemOperations command with the DeliveryMethodForFetch setting to inline
            DataStructures.ItemOperations itemOperationsItemInline = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, bodyPreferences, null, DeliveryMethodForFetch.Inline);

            Site.Assert.IsNotNull(
                itemOperationsItemInline.Email.Body,
                "The Body element should be included in response when new item is created.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R405
            Site.CaptureRequirementIfIsNull(
                itemOperationsItemInline.Email.Body.Part,
                405,
                @"[In Part] This element MUST NOT be present in non-multipart responses.");
            #endregion

            #region Call ItemOperations command with the DeliveryMethodForFetch setting to MultiPart
            DataStructures.ItemOperations itemOperationsItemMultiPart = this.GetItemOperationsResult(this.User2Information.InboxCollectionId, syncItem.ServerId, null, bodyPreferences, null, DeliveryMethodForFetch.MultiPart);

            Site.Assert.IsNotNull(
                itemOperationsItemMultiPart.Email.Body,
                "The Body element should be included in response when new item is created.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R244
            Site.CaptureRequirementIfIsNotNull(
                itemOperationsItemMultiPart.Email.Body.Part,
                244,
                @"[In Part] This element [the Part element] MUST be present in multipart responses, as specified in [MS-ASCMD] section 2.2.2.9.1.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R176
            Site.CaptureRequirementIfIsNull(
                itemOperationsItemMultiPart.Email.Body.Data,
                176,
                @"[In Data (Body)] This element [the Data (Body) element] MUST NOT be present in multipart responses, as specified in [MS-ASCMD] section 2.2.2.9.1.");
            #endregion
        }
        public void MSASAIRS_S04_TC06_MultipleBodyPreferenceHaveSameTypeValue()
        {
            #region Send a plain text email
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

            // Make sure the email has reached the inbox folder of the recipient
            this.GetSyncResult(subject, this.User2Information.InboxCollectionId, null, null, null);
            #endregion

            #region Set two BodyPreference elements with same type value
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 1,
                    TruncationSize = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone = true,
                    AllOrNoneSpecified = true
                },

                new Request.BodyPreference()
                {
                    Type = 1,
                    TruncationSize = 100,
                    TruncationSizeSpecified = true,
                    AllOrNone = true,
                    AllOrNoneSpecified = true
                }
            };
            #endregion

            #region Verify multiple BodyPreference elements with same type value in Sync for related requirements
            SyncRequest request = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User2Information.InboxCollectionId), this.User2Information.InboxCollectionId, null, bodyPreference, null);

            if (Common.IsRequirementEnabled(10015, this.Site))
            {
                try
                {
                    this.ASAIRSAdapter.Sync(request);

                    Site.Assert.Fail("The server should return an HTTP error 500 if multiple BodyPreference elements are present with the same value in the Type child element.");
                }
                catch (WebException exception)
                {
                    int errorCode = ((HttpWebResponse)exception.Response).StatusCode.GetHashCode();

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

                    // Verify MS-ASAIRS requirement: MS-ASAIRS_R10015
                    Site.CaptureRequirementIfAreEqual<int>(
                        500,
                        errorCode,
                        10015,
                        @"[In Appendix B: Product Behavior] Implementation does return an HTTP error 500 instead of a Status value of 4 when multiple BodyPreference elements are present with the same value in the Type child element. (<1> Section 3.2.5.1:  Exchange 2007 SP1 returns an HTTP error 500 instead of a Status value of 4 when multiple BodyPreference elements are present with the same value in the Type child element.)");
                }
            }

            if (Common.IsRequirementEnabled(10016, this.Site))
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(request.GetRequestDataSerializedXML());

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

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

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

                // Verify MS-ASAIRS requirement: MS-ASAIRS_R10016
                Site.CaptureRequirementIfAreEqual(
                    "4",
                    status,
                    10016,
                    @"[In Appendix B: Product Behavior] Implementation does return 4 (for Sync command) if multiple BodyPreference elements are present with the same value in the Type child element. (Exchange Server 2010 and above follow this behavior.)");
            }
            #endregion
        }
        public void MSASAIRS_S02_TC03_BodyPreference_AllOrNoneFalse_TruncatedContentReturned()
        {
            #region Send a plain text email and get the non-truncated data
            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 = 8,
                    TruncationSizeSpecified = true,
                    AllOrNone = false,
                    AllOrNoneSpecified = true
                }
            };
            #endregion

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

            this.VerifyBodyElements(syncItem.Email.Body, 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>(
                body.Substring(0, (int)bodyPreference[0].TruncationSize),
                syncItem.Email.Body.Data,
                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, bodyPreference, null, null);

            this.VerifyBodyElements(itemOperationsItem.Email.Body, 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>(
                body.Substring(0, (int)bodyPreference[0].TruncationSize),
                itemOperationsItem.Email.Body.Data,
                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, bodyPreference, null);

            this.VerifyBodyElements(searchItem.Email.Body, 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>(
                body.Substring(0, (int)bodyPreference[0].TruncationSize),
                searchItem.Email.Body.Data,
                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_R180 can be captured directly
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASAIRS_R180");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R180
            Site.CaptureRequirement(
                180,
                @"[In Data (Body)] If the Truncated element (section 2.2.2.39.1) is included in the response, the data in the Data element is truncated.");
            #endregion
        }
        public void MSASAIRS_S02_TC09_Body_Preview()
        {
            Site.Assume.AreNotEqual<string>("12.1", Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site), "The Preview 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 Send a plain text email and get the none truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

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

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

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

            this.VerifyBodyPreview(syncItem.Email, allContentItem.Email, bodyPreference);
            #endregion

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

            this.VerifyBodyPreview(itemOperationsItem.Email, allContentItem.Email, bodyPreference);
            #endregion

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

            this.VerifyBodyPreview(searchItem.Email, allContentItem.Email, bodyPreference);
            #endregion

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R248
            Site.CaptureRequirement(
                248,
                @"[In Preview (Body)] The Preview element is an optional child element of the Body element (section 2.2.2.9) 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_R250");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R250
            Site.CaptureRequirement(
                250,
                @"[In Preview (Body)] 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_R2644");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R2644
            Site.CaptureRequirement(
                2644,
                @"[In Preview (BodyPreference)] [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_S02_TC05_BodyPreference_NoAllOrNone_TruncatedContentReturned()
        {
            #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 = 8,
                    TruncationSizeSpecified = true,
                }
            };
            #endregion

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

            this.VerifyBodyElements(syncItem.Email.Body, null, true, true);

            Site.Assert.AreEqual<string>(
                body.Substring(0, (int)bodyPreference[0].TruncationSize),
                syncItem.Email.Body.Data,
                "The server should return the data truncated to the size requested by TruncationSize when the AllOrNone element is not included in the request and the available data exceeds the truncation size.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R420
            Site.CaptureRequirement(
                420,
                @"[In AllOrNone (BodyPreference)] If the AllOrNone element is not included in the request, then the truncated 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, bodyPreference, null, null);

            this.VerifyBodyElements(itemOperationsItem.Email.Body, null, true, true);

            Site.Assert.AreEqual<string>(
                body.Substring(0, (int)bodyPreference[0].TruncationSize),
                itemOperationsItem.Email.Body.Data,
                "The server should return the data truncated to the size requested by TruncationSize when the AllOrNone element is not included in the request and the available data exceeds the truncation size.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R421
            Site.CaptureRequirement(
                421,
                @"[In AllOrNone (BodyPreference)] If the AllOrNone element is not included in the request, then the truncated 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, bodyPreference, null);

            this.VerifyBodyElements(searchItem.Email.Body, null, true, true);

            Site.Assert.AreEqual<string>(
                body.Substring(0, (int)bodyPreference[0].TruncationSize),
                searchItem.Email.Body.Data,
                "The server should return the data truncated to the size requested by TruncationSize when the AllOrNone element is not included in the request and the available data exceeds the truncation size.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R73
            Site.CaptureRequirement(
                73,
                @"[In AllOrNone (BodyPreference)] If the AllOrNone element is not included in the request, then the truncated content is searched as if the value was set to 0 (FALSE).");
            #endregion

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R276
            Site.CaptureRequirement(
                276,
                @"[In Truncated (Body)] If the value [of the Truncated element] is TRUE, then the body of the item has been truncated.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R77
            Site.CaptureRequirement(
                77,
                @"[In AllOrNone (BodyPreference)] [A client can include multiple BodyPreference 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).");
            #endregion
        }
예제 #43
0
        /// <summary>
        /// Build a generic Sync request without command references by using the specified sync key, folder collection ID and body preference option.
        /// If syncKey is
        /// In general, returns the XML formatted Sync request as follows:
        /// <!--
        /// <?xml version="1.0" encoding="utf-8"?>
        /// <Sync xmlns="AirSync">
        ///   <Collections>
        ///     <Collection>
        ///       <SyncKey>0</SyncKey>
        ///       <CollectionId>5</CollectionId>
        ///       <DeletesAsMoves>1</DeletesAsMoves>
        ///       <GetChanges>1</GetChanges>
        ///       <WindowSize>100</WindowSize>
        ///       <Options>
        ///         <MIMESupport>0</MIMESupport>
        ///         <airsyncbase:BodyPreference>
        ///           <airsyncbase:Type>2</airsyncbase:Type>
        ///           <airsyncbase:TruncationSize>5120</airsyncbase:TruncationSize>
        ///         </airsyncbase:BodyPreference>
        ///       </Options>
        ///     </Collection>
        ///   </Collections>
        /// </Sync>
        /// -->
        /// </summary>
        /// <param name="syncKey">Specify the sync key obtained from the last sync response(Refer to [MS-ASCMD]2.2.3.166.4)</param>
        /// <param name="collectionId">Specify the server ID of the folder to be synchronized, which can be returned by ActiveSync FolderSync command(Refer to [MS-ASCMD]2.2.3.30.5)</param>
        /// <param name="bodyPreference">Sets preference information related to the type and size of information for body (Refer to [MS-ASAIRS] 2.2.2.7)</param>
        /// <returns>Returns the SyncRequest instance</returns>
        internal static SyncRequest CreateSyncRequest(string syncKey, string collectionId, Request.BodyPreference bodyPreference)
        {
            Request.SyncCollection syncCollection = new Request.SyncCollection
            {
                SyncKey      = syncKey,
                CollectionId = collectionId
            };

            if (syncKey != "0")
            {
                syncCollection.GetChanges          = true;
                syncCollection.GetChangesSpecified = true;
            }

            syncCollection.WindowSize = "100";

            Request.Options syncOptions     = new Request.Options();
            List <object>   syncOptionItems = new List <object>();
            List <Request.ItemsChoiceType1> syncOptionItemsName = new List <Request.ItemsChoiceType1>();

            if (null != bodyPreference)
            {
                syncOptionItemsName.Add(Request.ItemsChoiceType1.BodyPreference);
                syncOptionItems.Add(bodyPreference);

                // when body format is mime (Refer to [MS-ASAIRS] 2.2.2.22 Type)
                if (bodyPreference.Type == 0x4)
                {
                    syncOptionItemsName.Add(Request.ItemsChoiceType1.MIMESupport);

                    // Magic number '2' indicate server send MIME data for all messages but not S/MIME messages only
                    syncOptionItems.Add((byte)0x2);
                }
            }

            syncOptions.Items            = syncOptionItems.ToArray();
            syncOptions.ItemsElementName = syncOptionItemsName.ToArray();
            syncCollection.Options       = new Request.Options[] { syncOptions };

            return(Common.CreateSyncRequest(new Request.SyncCollection[] { syncCollection }));
        }
        public void MSASAIRS_S02_TC06_BodyPreference_NoAllOrNone_NonTruncatedContentReturned()
        {
            #region Send a plain text email and get the non-truncated data
            string subject = Common.GenerateResourceName(Site, "Subject");
            string body = Common.GenerateResourceName(Site, "Body");
            this.SendEmail(EmailType.Plaintext, subject, body);

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

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

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

            this.VerifyBodyElements(syncItem.Email.Body, null, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R423
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.Body.Data,
                syncItem.Email.Body.Data,
                423,
                @"[In AllOrNone (BodyPreference)] If the AllOrNone element is not included in the request, then the non-truncated 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, bodyPreference, null, null);

            this.VerifyBodyElements(itemOperationsItem.Email.Body, null, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R424
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.Body.Data,
                itemOperationsItem.Email.Body.Data,
                424,
                @"[In AllOrNone (BodyPreference)] If the AllOrNone element is not included in the request, then the non-truncated 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, bodyPreference, null);

            this.VerifyBodyElements(searchItem.Email.Body, null, false, true);

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R422
            Site.CaptureRequirementIfAreEqual<string>(
                allContentItem.Email.Body.Data,
                searchItem.Email.Body.Data,
                422,
                @"[In AllOrNone (BodyPreference)] If the AllOrNone element is not included in the request, then the non-truncated content is searched as if the value was set to 0 (FALSE).");
            #endregion

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R277
            Site.CaptureRequirement(
                277,
                @"[In Truncated (Body)] 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
        }
예제 #45
0
        /// <summary>
        /// Get the size of the Data of an email's Body.
        /// </summary>
        /// <param name="emailSubject">The email's subject.</param>
        /// <param name="valueOfMIMETruncation">The value of MIMETruncation, which is in the range of [1,7].</param>
        /// <returns>The size of the Data of the email's Body.</returns>
        private int GetEmailBodyDataSize(string emailSubject, byte valueOfMIMETruncation)
        {
            Site.Assert.IsTrue(!string.IsNullOrEmpty(emailSubject), "The email subject should not be null or empty.");
            Site.Assert.IsTrue(0 < valueOfMIMETruncation && valueOfMIMETruncation < 8, "The value of MIMETruncation should be in the range of [1,7]");

            Request.BodyPreference bodyPreference = new Request.BodyPreference { Type = 4 };

            Request.Options option = new Request.Options
            {
                Items = new object[] { (byte)2, bodyPreference, valueOfMIMETruncation },
                ItemsElementName =
                    new Request.ItemsChoiceType1[]
                    {
                        Request.ItemsChoiceType1.MIMESupport, Request.ItemsChoiceType1.BodyPreference,
                        Request.ItemsChoiceType1.MIMETruncation
                    }
            };

            SyncResponse syncResponse = this.CheckEmail(this.User2Information.InboxCollectionId, emailSubject, new Request.Options[] { option });

            Response.Body mailBody = GetMailBody(syncResponse, emailSubject);
            Site.Assert.IsNotNull(mailBody, "The body of the received email should not be null.");
            Site.Assert.IsNotNull(mailBody.Data, "The Data of the received email's body should not be null.");

            return mailBody.Data.Length;
        }
        public void MSASAIRS_S02_TC08_MultipleBodyPreference()
        {
            #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[] bodyPreferences = new Request.BodyPreference[2]
            {
                new Request.BodyPreference()
                {
                    Type = 2,
                    TruncationSize = 8,
                    TruncationSizeSpecified = true,
                    AllOrNone = true,
                    AllOrNoneSpecified = true
                },
                new Request.BodyPreference()
                {
                    Type = 1,
                    TruncationSize = 18,
                    TruncationSizeSpecified = true
                }
            };
            #endregion

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

            this.VerifyMultipleBodyPreference(syncItem.Email, body, bodyPreferences);
            #endregion

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

            this.VerifyMultipleBodyPreference(itemOperationsItem.Email, body, bodyPreferences);
            #endregion

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

            this.VerifyMultipleBodyPreference(searchItem.Email, body, bodyPreferences);
            #endregion

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R80
            Site.CaptureRequirement(
                80,
                @"[In AllOrNone (BodyPreference)] In this case [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], if the client has specified multiple BodyPreference elements, the server selects the next BodyPreference element that will return the maximum amount of body text to the client.");
            #endregion
        }
예제 #47
0
        /// <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 MSASAIRS_S02_TC11_TruncatedPresentOrNotInRequest()
        {
            bool isTruncatedSupported = Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("12.1")
                || Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.0")
                || Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site).Equals("14.1");
            Site.Assume.IsTrue(isTruncatedSupported, "The Truncated element is only supported when the MS-ASProtocolVersion header is set to 12.1, 14.0 and 14.1. MS-ASProtocolVersion header value is determined using Common PTFConfig property named ActiveSyncProtocolVersion.");

            #region Add three contacts with or without the Truncated element
            List<object> commandList = new List<object>();
            string data = Common.GenerateResourceName(Site, "ContactData");

            string fileAsWithoutTruncated = Common.GenerateResourceName(Site, "ContactWithoutTruncated");
            Request.SyncCollectionAdd syncAdd = CreateSyncAddContact(fileAsWithoutTruncated, data, null);
            commandList.Add(syncAdd);

            string fileAsWithTruncatedTrue = Common.GenerateResourceName(Site, "ContactWithTruncatedTrue");
            syncAdd = CreateSyncAddContact(fileAsWithTruncatedTrue, data, true);
            commandList.Add(syncAdd);

            string fileAsWithTruncatedFalse = Common.GenerateResourceName(Site, "ContactWithTruncatedFalse");
            syncAdd = CreateSyncAddContact(fileAsWithTruncatedFalse, data, false);
            commandList.Add(syncAdd);

            SyncRequest syncAddRequest = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User1Information.ContactsCollectionId), this.User1Information.ContactsCollectionId, commandList.ToArray(), null, null);

            DataStructures.SyncStore syncAddResponse = this.ASAIRSAdapter.Sync(syncAddRequest);
            Site.Assert.AreEqual<byte>(
                1,
                syncAddResponse.CollectionStatus,
                "The server should return a status 1 to indicate the Sync Add operation is successful.");

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, fileAsWithoutTruncated, fileAsWithTruncatedTrue, fileAsWithTruncatedFalse);
            #endregion

            #region Set BodyPreference element
            Request.BodyPreference[] bodyPreference = new Request.BodyPreference[]
            {
                new Request.BodyPreference()
                {
                    Type = 1
                }
            };
            #endregion

            #region Sychronize the three contacts
            SyncRequest syncRequest = TestSuiteHelper.CreateSyncRequest(this.GetInitialSyncKey(this.User1Information.ContactsCollectionId), this.User1Information.ContactsCollectionId, null, bodyPreference, null);

            DataStructures.SyncStore contacts = this.ASAIRSAdapter.Sync(syncRequest);

            DataStructures.Sync contactWithoutTruncated = TestSuiteHelper.GetSyncAddItem(contacts, fileAsWithoutTruncated);
            this.VerifySyncItem(contactWithoutTruncated);

            DataStructures.Sync contactWithTruncatedTrue = TestSuiteHelper.GetSyncAddItem(contacts, fileAsWithTruncatedTrue);
            this.VerifySyncItem(contactWithTruncatedTrue);

            DataStructures.Sync contactWithTruncatedFalse = TestSuiteHelper.GetSyncAddItem(contacts, fileAsWithTruncatedFalse);
            this.VerifySyncItem(contactWithTruncatedFalse);

            Site.Log.Add(
                LogEntryKind.Debug,
                "Content without including Truncated in request: {0}; content with Truncated TRUE: {1}; content with Truncated FALSE: {2}.",
                contactWithoutTruncated.Contact.Body.Data,
                contactWithTruncatedTrue.Contact.Body.Data,
                contactWithTruncatedFalse.Contact.Body.Data);

            Site.Assert.IsTrue(
                contactWithoutTruncated.Contact.Body.Data == contactWithTruncatedTrue.Contact.Body.Data &&
                contactWithTruncatedTrue.Contact.Body.Data == contactWithTruncatedFalse.Contact.Body.Data,
                "The data should be same whenever the Truncated present or not in a request.");
            #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_R11500");

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R11500
            Site.CaptureRequirement(
                11500,
                @"[In Body] Reply is the same whether this element[Truncated] is used in a command request.");

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

            // Verify MS-ASAIRS requirement: MS-ASAIRS_R406
            Site.CaptureRequirement(
                406,
                @"[In Truncated (Body)] The server will return the same response no matter what the value of Truncated element is.");
            #endregion
        }
예제 #49
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 MSASCNTC_S02_TC02_ItemOperations_TruncateBody()
        {
            #region Call Sync command with Add element to add a contact with all Contact class elements to the server
            string picture = "SmallPhoto.jpg";

            Dictionary<Request.ItemsChoiceType8, object> contactProperties = this.SetContactProperties(picture);
            this.AddContact(this.User1Information.ContactsCollectionId, contactProperties);

            this.RecordCaseRelativeItems(this.User1Information.UserName, this.User1Information.ContactsCollectionId, contactProperties[Request.ItemsChoiceType8.FileAs].ToString());

            // Get the new added contact
            Sync newAddedItem = this.GetSyncAddResult(contactProperties[Request.ItemsChoiceType8.FileAs].ToString(), this.User1Information.ContactsCollectionId, null, null);
            #endregion

            #region Call ItemOperations command with TruncationSize element smaller than the available data of the body
            Request.BodyPreference bodyPreference = new Request.BodyPreference
            {
                Type = 1,
                TruncationSize = 8,
                TruncationSizeSpecified = true
            };

            ItemOperations item = this.GetItemOperationsResult(this.User1Information.ContactsCollectionId, newAddedItem.ServerId, bodyPreference, null);

            // Assert the body data is truncated.
            Site.Assert.AreEqual<string>(
                ((Request.Body)contactProperties[Request.ItemsChoiceType8.Body]).Data.Substring(0, (int)bodyPreference.TruncationSize),
                item.Contact.Body.Data,
                "The body data should be truncated when the value of TruncationSize element is smaller than the available data size.");
            #endregion
        }
예제 #51
0
        /// <summary>
        /// Get the specified email item.
        /// </summary>
        /// <param name="emailSubject">The subject of the email item.</param>
        /// <param name="folderCollectionId">The serverId of the default folder.</param>
        /// <param name="bodyPreference">The preference information related to the type and size of information that is returned from fetching.</param>
        /// <returns>The result of getting the specified email item.</returns>
        private SyncStore GetSyncResult(string emailSubject, string folderCollectionId, Request.BodyPreference bodyPreference)
        {
            SyncStore syncItemResult;

            Microsoft.Protocols.TestSuites.Common.DataStructures.Sync item = null;
            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);

                // Get the new added email item
                syncItemResult = this.SyncChanges(this.GetInitialSyncKey(folderCollectionId), folderCollectionId, bodyPreference);
                if (syncItemResult != null && syncItemResult.CollectionStatus == 1)
                {
                    item = TestSuiteHelper.GetSyncAddItem(syncItemResult, emailSubject);
                }

                counter++;
            }while ((syncItemResult == null || item == null) && counter < retryCount);

            Site.Assert.IsNotNull(item, "The email item with subject {0} should be found. Retry count: {1}", emailSubject, counter);

            // Verify sync result
            Site.Assert.AreEqual <byte>(
                1,
                syncItemResult.CollectionStatus,
                "If the Sync command executes successfully, the status in response should be 1.");

            return(syncItemResult);
        }