The wrapper class for the search result returned from the server
Пример #1
0
        public void MSASCON_S05_TC03_Search_Status164()
        {
            this.CheckActiveSyncVersionIsNot140();

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

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

            if (Common.IsRequirementEnabled(220, this.Site))
            {
                #region Call Search command with BodyPartPreference element and set the Type element to 3
                this.SwitchUser(this.User1Information, false);

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

                SearchRequest searchRequest            = TestSuiteHelper.GetSearchRequest(syncItem.Email.ConversationId, bodyPartPreference, null);
                DataStructures.SearchStore searchStore = this.CONAdapter.Search(searchRequest, false, 0);
                this.VerifyMessagePartStatus164(byte.Parse(searchStore.StoreStatus));
                #endregion
            }
        }
Пример #2
0
        public void MSASCON_S05_TC01_Search()
        {
            #region Create a conversation and get the created conversation item.
            string           conversationSubject    = Common.GenerateResourceName(Site, "Conversation");
            ConversationItem sourceConversationItem = this.CreateConversation(conversationSubject);
            #endregion

            #region Call MoveItems command to move one item of the conversation from Inbox folder to SentItems folder.
            Collection <string> moveItems = new Collection <string> {
                sourceConversationItem.ServerId[0]
            };

            // Call MoveItems command to move one item of the conversation from Inbox folder to SentItems folder.
            this.CallMoveItemsCommand(moveItems, User1Information.InboxCollectionId, User1Information.SentItemsCollectionId);
            TestSuiteBase.RecordCaseRelativeItems(this.User1Information, User1Information.SentItemsCollectionId, conversationSubject, false);
            #endregion

            #region Call Search command to find the conversation.
            DataStructures.SearchStore searchResponse = this.CallSearchCommand(sourceConversationItem.ConversationId, 2, null, null);

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

            // Verify MS-ASCON requirement: MS-ASCON_R221
            // The Search command executed successfully, so this requirement can be captured.
            Site.CaptureRequirement(
                221,
                @"[In Processing a Search Command] The server sends a Search command response, as specified in [MS-ASCMD] section 2.2.2.14.");

            Site.Assert.AreEqual <int>(searchResponse.Results.Count, sourceConversationItem.ServerId.Count, "The count of the search result should be equal to the count of items in the conversation.");

            // If one of the found email is in Inbox folder and the other is in Sent Items folder, this requirement can be captured.
            bool allFoldersSearched = (searchResponse.Results[0].CollectionId == User1Information.InboxCollectionId && searchResponse.Results[1].CollectionId == User1Information.SentItemsCollectionId) || (searchResponse.Results[1].CollectionId == User1Information.InboxCollectionId && searchResponse.Results[0].CollectionId == User1Information.SentItemsCollectionId);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R176");
            Site.Log.Add(LogEntryKind.Debug, "The emails found are in folders with CollectionId {0} and {1}.", searchResponse.Results[0].CollectionId, searchResponse.Results[1].CollectionId);

            // Verify MS-ASCON requirement: MS-ASCON_R176
            Site.CaptureRequirementIfIsTrue(
                allFoldersSearched,
                176,
                @"[In Finding a Conversation] Searching for a particular conversation will search across all folders for all e-mail messages that are in the conversation.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R220");
            Site.Log.Add(LogEntryKind.Debug, "The emails found are in folders with CollectionId {0} and {1}.", searchResponse.Results[0].CollectionId, searchResponse.Results[1].CollectionId);

            // Verify MS-ASCON requirement: MS-ASCON_R220
            Site.CaptureRequirementIfIsTrue(
                allFoldersSearched,
                220,
                @"[In Processing a Search Command] When the server receives a request to find a conversation, as specified in section 3.1.4.7, the server searches across all folders for all e-mail messages that are in the conversation and returns this set of e-mail messages.");
            #endregion
        }
Пример #3
0
        /// <summary>
        /// Search item with specified criteria on the server.
        /// </summary>
        /// <param name="subject">The subject of the item.</param>
        /// <param name="collectionId">The collection id.</param>
        /// <param name="conversationId">The conversation for which to search.</param>
        /// <param name="bodyPreferences">The bodyPreference in the options element.</param>
        /// <param name="bodyPartPreferences">The bodyPartPreference in the options element.</param>
        /// <returns>The server response.</returns>
        protected DataStructures.Search GetSearchResult(string subject, string collectionId, string conversationId, Request.BodyPreference[] bodyPreferences, Request.BodyPartPreference[] bodyPartPreferences)
        {
            SearchRequest request = TestSuiteHelper.CreateSearchRequest(subject, collectionId, conversationId, bodyPreferences, bodyPartPreferences);

            DataStructures.SearchStore searchStore = this.ASAIRSAdapter.Search(request);
            DataStructures.Search      searchItem  = null;
            if (searchStore.Results.Count != 0)
            {
                searchItem = TestSuiteHelper.GetSearchItem(searchStore, subject);
            }

            this.Site.Assert.IsNotNull(searchItem, "The email message with subject {0} should be found.", subject);

            return(searchItem);
        }
        /// <summary>
        /// Get the email item from the Search response by using the subject as the search criteria.
        /// </summary>
        /// <param name="searchStore">The Search command result.</param>
        /// <param name="fileAs">The FileAs of the contact.</param>
        /// <returns>The email item corresponds to the specified subject.</returns>
        internal static DataStructures.Search GetSearchItem(DataStructures.SearchStore searchStore, string fileAs)
        {
            DataStructures.Search searchItem = null;
            if (searchStore.Results.Count > 0)
            {
                foreach (DataStructures.Search item in searchStore.Results)
                {
                    if (item.Contact.FileAs == fileAs)
                    {
                        searchItem = item;
                        break;
                    }
                }
            }

            return(searchItem);
        }
Пример #5
0
        /// <summary>
        /// Get the email item from the Search response by using the subject as the search criteria.
        /// </summary>
        /// <param name="searchStore">The Search command result.</param>
        /// <param name="subject">The email subject.</param>
        /// <returns>The email item corresponds to the specified subject.</returns>
        internal static DataStructures.Search GetSearchItem(DataStructures.SearchStore searchStore, string subject)
        {
            DataStructures.Search searchItem = null;
            if (searchStore.Results.Count > 0)
            {
                foreach (DataStructures.Search item in searchStore.Results)
                {
                    if (item.Email.Subject == subject)
                    {
                        searchItem = item;
                        break;
                    }

                    if (item.Calendar.Subject == subject)
                    {
                        searchItem = item;
                        break;
                    }
                }
            }

            return(searchItem);
        }
        /// <summary>
        /// Verify the rights-managed requirements about Search response.
        /// </summary>
        /// <param name="searchStore">The wrapper class for the result of Search command.</param>
        private void VerifySearchResponse(SearchStore searchStore)
        {
            foreach (Search search in searchStore.Results)
            {
                if (search.Email != null)
                {
                    if (search.Email.RightsManagementLicense != null)
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASRM_R211");

                        // Verify MS-ASRM requirement: MS-ASRM_R211
                        Site.CaptureRequirementIfIsTrue(
                            this.activeSyncClient.ValidationResult,
                            211,
                            @"[In Sending Rights-Managed E-Mail Messages to the Client] In a Search command response, the RightsManagementLicense element is included as a child of the search:Properties element ([MS-ASCMD] section 2.2.3.128.2).");

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

                        // Verify MS-ASRM requirement: MS-ASRM_R411
                        Site.CaptureRequirementIfIsTrue(
                            this.activeSyncClient.ValidationResult,
                            411,
                            @"[In Sending Rights-Managed E-Mail Messages to the Client] To respond to a Search command request message that includes the RightsManagementSupport element, the server includes the RightsManagementLicense element and its child elements in the Search command response message.");

                        this.VerifyRightsManagementLicense(search.Email.RightsManagementLicense);
                    }
                }
            }
        }
        /// <summary>
        /// This method is used to verify the Search response related requirement.
        /// </summary>
        /// <param name="searchResponse">Specified SearchStore result returned from the server.</param>
        private void VerifySearchCommandResponse(SearchStore searchResponse)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R351");

            // Verify MS-ASTASK requirement: MS-ASTASK_R351
            Site.CaptureRequirementIfAreEqual<string>(
                "1",
                searchResponse.Status,
                351,
                @"[In Searching for Task Data][If the client sends a search command request to the server] The server responds with a Search command response ([MS-ASCMD] section 2.2.2.14).");
        }
        /// <summary>
        /// This method is used to verify the Search command response related requirements.
        /// </summary>
        /// <param name="searchStore">The Search result from the server.</param>
        private void VerifySearchResponse(SearchStore searchStore)
        {
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R475");

            // Verify MS-ASCNTC requirement: MS-ASCNTC_R475
            Site.CaptureRequirementIfIsTrue(
                this.activeSyncClient.ValidationResult,
                475,
                @"[In Searching for Contact Data] [If a client sends a Search command request to the server]The server responds with a Search command response ([MS-ASCMD] section 2.2.2.14).");

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

            // Verify MS-ASCNTC requirement: MS-ASCNTC_R488
            Site.CaptureRequirementIfIsTrue(
                this.activeSyncClient.ValidationResult,
                488,
                @"[In Search Command Response] When a client uses the Search command request ([MS-ASCMD] section 2.2.2.14) to retrieve Contact class items that match the criteria specified by the client, as specified in section 3.1.5.2, the server responds with a Search command response ([MS-ASCMD] section 2.2.2.14).");

            // If the validation is successful, then MS-ASCNTC_R490 can be captured.
            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCNTC_R490");

            // Verify MS-ASCNTC requirement: MS-ASCNTC_R490
            Site.CaptureRequirementIfIsTrue(
                this.activeSyncClient.ValidationResult,
                490,
                @"[In Search Command Response] Contact class elements are returned as child elements of the search:Properties element ([MS-ASCMD] section 2.2.3.128) in the Search command response.");

            foreach (Search search in searchStore.Results)
            {
                if (search.Contact != null)
                {
                    this.VerifyContactClassElements(search.Contact);
                }
            }

            this.VerifyMessageSyntax();
            this.VerifyAbstractDataModel();
        }
Пример #9
0
        /// <summary>
        /// Load the SearchStore from the SearchResponse
        /// </summary>
        /// <param name="search">The returned Search response.</param>
        /// <returns>A SearchStore instance</returns>
        public static DataStructures.SearchStore LoadSearchResponse(SearchResponse search)
        {
            DataStructures.SearchStore searchStore = new DataStructures.SearchStore();

            if (search.ResponseData.Status != null)
            {
                searchStore.Status = search.ResponseData.Status;

                if (!searchStore.Status.Equals("1"))
                {
                    return searchStore;
                }
            }

            searchStore.StoreStatus = search.ResponseData.Response.Store.Status;

            if (!searchStore.StoreStatus.Equals("1"))
            {
                return searchStore;
            }

            searchStore.Range = search.ResponseData.Response.Store.Range;

            if (!string.IsNullOrEmpty(search.ResponseData.Response.Store.Total))
            {
                searchStore.Total = Convert.ToInt32(search.ResponseData.Response.Store.Total, CultureInfo.InvariantCulture);
            }

            if (search.ResponseData.Response.Store.Result == null)
            {
                return searchStore;
            }

            if (search.ResponseData.Response.Store.Result.Length == 1 && search.ResponseData.Response.Store.Result[0].CollectionId == null)
            {
                return searchStore;
            }

            foreach (Response.SearchResponseStoreResult result in search.ResponseData.Response.Store.Result)
            {
                DataStructures.Search searchResult = new DataStructures.Search
                {
                    LongId = result.LongId,
                    Class = result.Class,
                    CollectionId = result.CollectionId,
                    Note = DataStructures.Note.DeserializeFromSearchProperties<DataStructures.Note>(result.Properties),
                    Calendar = DataStructures.Calendar.DeserializeFromSearchProperties<DataStructures.Calendar>(result.Properties),
                    Contact = DataStructures.Contact.DeserializeFromSearchProperties<DataStructures.Contact>(result.Properties),
                    Email = DataStructures.Email.DeserializeFromSearchProperties<DataStructures.Email>(result.Properties),
                    Task = DataStructures.Task.DeserializeFromSearchProperties<DataStructures.Task>(result.Properties)
                };

                searchStore.Results.Add(searchResult);
            }

            return searchStore;
        }
Пример #10
0
        public void MSASCON_S05_TC02_Search_MessagePart()
        {
            if (Common.IsRequirementEnabled(221, this.Site))
            {
                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

                if (Common.IsRequirementEnabled(220, this.Site))
                {
                    #region Call Search 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.SearchStore searchStore = this.CallSearchCommand(syncItem.Email.ConversationId, 1, null, null);
                    this.VerifyMessagePartWithoutPreference(searchStore.Results[0].Email);

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

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

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

                    searchStore = this.CallSearchCommand(syncItem.Email.ConversationId, 1, null, bodyPreference);
                    this.VerifyMessagePartWithBodyPreference(searchStore.Results[0].Email);
                    #endregion

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

                    searchStore     = this.CallSearchCommand(syncItem.Email.ConversationId, 1, bodyPartPreference, null);
                    lastRawResponse = (XmlElement)this.CONAdapter.LastRawResponseXml;
                    string truncatedData = TestSuiteHelper.GetDataInnerText(lastRawResponse, "BodyPart", "Data", subject);
                    this.VerifyMessagePartWithBodyPartPreference(searchStore.Results[0].Email, truncatedData, allData, (int)bodyPartPreference.TruncationSize);

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

                    // Verify MS-ASCON requirement: MS-ASCON_R235
                    Site.CaptureRequirementIfIsNotNull(
                        searchStore.Results[0].Email.BodyPart,
                        235,
                        @"[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_R40");

                    // A message part and its meta-data are encapsulated by BodyPart element in the Search response, so this requirement can be captured.
                    Site.CaptureRequirement(
                        40,
                        @"[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 Call Search command with both BodyPreference and BodyPartPreference elements.
                    searchStore = this.CallSearchCommand(syncItem.Email.ConversationId, 1, bodyPartPreference, bodyPreference);
                    this.VerifyMessagePartWithBothPreference(searchStore.Results[0].Email);
                    #endregion
                }
            }
        }