/// <summary> /// Builds a Search request on the Mailbox store by using the specified keyword and folder collection ID /// In general, returns the XML formatted search request as follows: /// <!-- /// <?xml version="1.0" encoding="utf-8"?> /// <Search xmlns="Search" xmlns:airsync="AirSync"> /// <Store> /// <Name>Mailbox</Name> /// <Query> /// <And> /// <airsync:CollectionId>5</airsync:CollectionId> /// <FreeText>Presentation</FreeText> /// </And> /// </Query> /// <Options> /// <RebuildResults /> /// <Range>0-9</Range> /// <DeepTraversal/> /// </Options> /// </Store> /// </Search> /// --> /// </summary> /// <param name="storeName">Specify the store for which to search. Refer to [MS-ASCMD] section 2.2.3.110.2</param> /// <param name="keyword">Specify a string value for which to search. Refer to [MS-ASCMD] section 2.2.3.73</param> /// <param name="collectionId">Specify the folder in which to search. Refer to [MS-ASCMD] section 2.2.3.30.4</param> /// <returns>Returns a SearchRequest instance</returns> internal static SearchRequest CreateSearchRequest(string storeName, string keyword, string collectionId) { if (null == keyword) { throw new ArgumentNullException("keyword", "keyword: Specify the value to search"); } if (null == collectionId) { throw new ArgumentNullException("collectionId", "folderCollectionId: Specify the folder ID to search"); } Request.SearchStore searchStore = new Request.SearchStore { Name = storeName, Options = new Request.Options1() }; Dictionary <Request.ItemsChoiceType6, object> items = new Dictionary <Request.ItemsChoiceType6, object> { { Request.ItemsChoiceType6.DeepTraversal, string.Empty }, { Request.ItemsChoiceType6.RebuildResults, string.Empty }, { Request.ItemsChoiceType6.Range, "0-9" } }; searchStore.Options.Items = items.Values.ToArray <object>(); searchStore.Options.ItemsElementName = items.Keys.ToArray <Request.ItemsChoiceType6>(); // Build up query condition by using the keyword and folder CollectionID Request.queryType queryItem = new Request.queryType { Items = new object[] { collectionId, keyword }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.CollectionId, Request.ItemsChoiceType2.FreeText } }; searchStore.Query = new Request.queryType { Items = new object[] { queryItem }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And } }; return(Common.CreateSearchRequest(new Request.SearchStore[] { searchStore })); }
/// <summary> /// Create a Search request using the specified keyword and folder collection ID /// </summary> /// <param name="keyword">Specify a string value for which to search.</param> /// <param name="folderCollectionId">Specify the folder in which to search.</param> /// <returns>A SearchRequest instance</returns> public static SearchRequest CreateSearchRequest(string keyword, string folderCollectionId) { Request.SearchStore searchStore = new Request.SearchStore { Name = SearchName.Mailbox.ToString(), Options = new Request.Options1 { Items = new object[] { string.Empty, string.Empty }, ItemsElementName = new Request.ItemsChoiceType6[] { Request.ItemsChoiceType6.RebuildResults, Request.ItemsChoiceType6.DeepTraversal } } }; // Build up query condition by using the keyword and folder CollectionID Request.queryType queryItem = new Request.queryType { Items = new object[] { folderCollectionId, keyword }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.CollectionId, Request.ItemsChoiceType2.FreeText } }; searchStore.Query = new Request.queryType { Items = new object[] { queryItem }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And } }; return Common.CreateSearchRequest(new Request.SearchStore[] { searchStore }); }
/// <summary> /// Builds a Search request on the Mailbox store by using the specified keyword and folder collection ID /// In general, returns the XML formatted search request as follows: /// <!-- /// <?xml version="1.0" encoding="utf-8"?> /// <Search xmlns="Search" xmlns:airsync="AirSync"> /// <Store> /// <Name>Mailbox</Name> /// <Query> /// <And> /// <airsync:CollectionId>5</airsync:CollectionId> /// <FreeText>Presentation</FreeText> /// </And> /// </Query> /// <Options> /// <RebuildResults /> /// <Range>0-9</Range> /// <DeepTraversal/> /// </Options> /// </Store> /// </Search> /// --> /// </summary> /// <param name="storeName">Specify the store for which to search. Refer to [MS-ASCMD] section 2.2.3.110.2</param> /// <param name="keyword">Specify a string value for which to search. Refer to [MS-ASCMD] section 2.2.3.73</param> /// <param name="collectionId">Specify the folder in which to search. Refer to [MS-ASCMD] section 2.2.3.30.4</param> /// <returns>Returns a SearchRequest instance</returns> internal static SearchRequest CreateSearchRequest(string storeName, string keyword, string collectionId) { if (null == keyword) { throw new ArgumentNullException("keyword", "keyword: Specify the value to search"); } if (null == collectionId) { throw new ArgumentNullException("collectionId", "folderCollectionId: Specify the folder ID to search"); } Request.SearchStore searchStore = new Request.SearchStore { Name = storeName, Options = new Request.Options1() }; Dictionary<Request.ItemsChoiceType6, object> items = new Dictionary<Request.ItemsChoiceType6, object> { { Request.ItemsChoiceType6.DeepTraversal, string.Empty }, { Request.ItemsChoiceType6.RebuildResults, string.Empty }, { Request.ItemsChoiceType6.Range, "0-9" } }; searchStore.Options.Items = items.Values.ToArray<object>(); searchStore.Options.ItemsElementName = items.Keys.ToArray<Request.ItemsChoiceType6>(); // Build up query condition by using the keyword and folder CollectionID Request.queryType queryItem = new Request.queryType { Items = new object[] { collectionId, keyword }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.CollectionId, Request.ItemsChoiceType2.FreeText } }; searchStore.Query = new Request.queryType { Items = new object[] { queryItem }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And } }; return Common.CreateSearchRequest(new Request.SearchStore[] { searchStore }); }
public void MSASCMD_S14_TC12_Search_Result_NoItemMatched() { #region User1 calls SendMail command to send an email message to user2. string keyword = Guid.NewGuid().ToString().Substring(0, 5); string emailSubject = Common.GenerateResourceName(Site, keyword); SendMailResponse responseSendMail = this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null); Site.Assert.AreEqual(string.Empty, responseSendMail.ResponseDataXML, "If SendMail command executes successfully, server should return empty xml data"); #endregion #region Sync user2 mailbox changes // Switch to user2 mailbox this.SwitchUser(this.User2Information); this.GetMailItem(this.User2Information.InboxCollectionId, emailSubject); TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject); #endregion #region Create a search request for searching mail. // Create one search query with GUID as search keyword, search should not get result with that keyword. string searchKeyword = Common.GenerateResourceName(Site, "search"); Request.queryType searchQuery = new Request.queryType { ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And }, 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.User2Information.InboxCollectionId, searchKeyword }; SearchRequest searchRequest = this.CreateDefaultSearchRequest(); searchRequest.RequestData.Items[0].Query = searchQuery; #endregion #region Call Search command SearchResponse searchResponse = this.CMDAdapter.Search(searchRequest); Site.Assert.AreEqual("1", searchResponse.ResponseData.Response.Store.Status, "If server successfully completed command, server should return status 1"); string statusCode = searchResponse.ResponseData.Status; XmlDocument doc = new XmlDocument(); doc.LoadXml(searchResponse.ResponseDataXML); XmlNodeList results = doc.GetElementsByTagName("Result"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3847"); // Verify MS-ASCMD requirement: MS-ASCMD_R3847 Site.CaptureRequirementIfIsTrue( statusCode.Equals("1") && results.Count == 1 && results[0].ChildNodes.Count == 0, 3847, @"[In Result(Search)] If no matches are found, an empty Result element is present in the Store container element of the response XML."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3850"); // Verify MS-ASCMD requirement: MS-ASCMD_R3850 Site.CaptureRequirementIfIsTrue( statusCode.Equals("1") && results.Count == 1 && results[0].ChildNodes.Count == 0, 3850, @"[In Result(Search)] If no matches are found, an empty Result element is present in the Store container element of the response XML."); #endregion }
public void MSASCMD_S14_TC13_Search_Result_MultipleMatchedItems() { #region User1 calls SendMail command to send 2 email messages to user2. string keyWord = Guid.NewGuid().ToString().Substring(0, 5); uint mailIndex = 1; string emailSubject = keyWord + Common.GenerateResourceName(Site, "search", mailIndex); SendMailResponse responseSendMail = this.SendPlainTextEmail(null, emailSubject, this.User1Information.UserName, this.User2Information.UserName, null); Site.Assert.AreEqual(string.Empty, responseSendMail.ResponseDataXML, "If SendMail command executes successfully, server should return empty xml data"); mailIndex++; string emailSubject2 = keyWord + Common.GenerateResourceName(Site, "search", mailIndex); SendMailResponse responseSendMail2 = this.SendPlainTextEmail(null, emailSubject2, this.User1Information.UserName, this.User2Information.UserName, null); Site.Assert.AreEqual(string.Empty, responseSendMail2.ResponseDataXML, "If SendMail command executes successfully, server should return empty xml data"); #endregion #region Sync user2 mailbox changes // Switch to user2 mailbox this.SwitchUser(this.User2Information); this.GetMailItem(this.User2Information.InboxCollectionId, emailSubject); this.GetMailItem(this.User2Information.InboxCollectionId, emailSubject2); TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject, emailSubject2); #endregion #region Create a search request for searching mail. Request.Options1 searchOption = new Request.Options1 { ItemsElementName = new Request.ItemsChoiceType6[] { Request.ItemsChoiceType6.DeepTraversal, Request.ItemsChoiceType6.RebuildResults, Request.ItemsChoiceType6.Range }, Items = new object[] { string.Empty, string.Empty, "0-2" } }; Request.queryType searchQuery = new Request.queryType { ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And }, 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.User2Information.InboxCollectionId, keyWord }; SearchRequest searchRequest = this.CreateDefaultSearchRequest(); searchRequest.RequestData.Items[0].Options = searchOption; searchRequest.RequestData.Items[0].Query = searchQuery; #endregion #region Call Search command int counter = 0; int waitTime = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site)); int retryCount = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site)); int sendMailCount = 2; int resultsCount; SearchResponse searchResponse; // Loop search to get correct results. do { Thread.Sleep(waitTime); searchResponse = this.CMDAdapter.Search(searchRequest); Site.Assert.AreEqual("1", searchResponse.ResponseData.Response.Store.Status, "If server successfully completed command, server should return status 1"); resultsCount = searchResponse.ResponseData.Response.Store.Result.Length; counter++; } while (resultsCount != sendMailCount && counter < retryCount); Site.Assert.AreEqual<int>(2, resultsCount, "Search response should contain two search results"); Site.Log.Add(LogEntryKind.Debug, "Loop {0} times to get the search item", counter); #endregion #region Verify Requirements MS-ASCMD_R3846, MS-ASCMD_R3849, MS-ASCMD_R3862, MS-ASCMD_R3851 // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3846"); // Verify MS-ASCMD requirement: MS-ASCMD_R3846 // User1 sends 2 emails to user2 with same keyWord, user2 searches Inbox folder with specified keyword and gets 2 results, then MS-ASCMD_R3846 is verified Site.CaptureRequirementIfIsTrue( searchResponse.ResponseData.Response.Store.Status.Equals("1") && resultsCount == 2, 3846, @"[In Result(Search)] One Result element is present for each match that is found."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3849"); // Verify MS-ASCMD requirement: MS-ASCMD_R3849 Site.CaptureRequirementIfIsTrue( searchResponse.ResponseData.Response.Store.Status.Equals("1") && resultsCount == 2 && searchResponse.ResponseData.Response.Store.Result[0].CollectionId.Equals(this.User2Information.InboxCollectionId) && searchResponse.ResponseData.Response.Store.Result[1].CollectionId.Equals(this.User2Information.InboxCollectionId), 3849, @"[In Result(Search)] When the store that is being searched is the mailbox, there is one Result element for each match that is found in the mailbox."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3862"); // Verify MS-ASCMD requirement: MS-ASCMD_R3862 Site.CaptureRequirementIfIsTrue( searchResponse.ResponseData.Response.Store.Result[0].Properties.ItemsElementName.Length > 0, 3862, @"[In Result(Search)] Inside the Result element, the Properties element contains a list of requested properties for the mailbox item."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R3851"); // Verify MS-ASCMD requirement: MS-ASCMD_R3851 Site.CaptureRequirementIfIsTrue( searchResponse.ResponseData.Response.Store.Result[0].CollectionId.Equals(this.User2Information.InboxCollectionId) && searchResponse.ResponseData.Response.Store.Result[0].Properties.ItemsElementName.Length > 0, 3851, @"[In Result(Search)] When the store that is being searched is the mailbox, inside the Result element, the Properties element contains a list of requested properties for the mailbox item."); #endregion }
/// <summary> /// Create Search GAL request. /// </summary> /// <param name="maxPictures">The maxPictures value.</param> /// <param name="maxSize">The maxSize value.</param> /// <param name="requestRange">The range value.</param> /// <param name="keyWord">The search key word.</param> /// <returns>The GAL search request.</returns> private SearchRequest CreateSearchGALRequest(uint maxPictures, uint maxSize, string requestRange, string keyWord) { // Create search request with range, maxSize, maxPictures options. Request.Options1 searchOption = new Request.Options1 { ItemsElementName = new Request.ItemsChoiceType6[] { Request.ItemsChoiceType6.Range, Request.ItemsChoiceType6.Picture } }; if (maxPictures > 0 && maxSize > 0) { Request.OptionsPicture picture = new Request.OptionsPicture { MaxPictures = maxPictures, MaxPicturesSpecified = true, MaxSize = maxSize, MaxSizeSpecified = true }; searchOption.Items = new object[] { requestRange, picture }; } else { searchOption.Items = new object[] { requestRange }; } Request.queryType searchQuery = new Request.queryType { Text = new string[] { keyWord } }; // Set Name element, option element, query element in default search request. SearchRequest searchRequest = this.CreateDefaultSearchRequest(); searchRequest.RequestData.Items[0].Name = SearchName.GAL.ToString(); searchRequest.RequestData.Items[0].Options = searchOption; searchRequest.RequestData.Items[0].Query = searchQuery; return searchRequest; }
/// <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; }
public void MSASCMD_S14_TC22_Search_WithDeepTraversal() { #region User1 calls SendMail command to send two emails to user2 string searchPrefix = "keyWord" + TestSuiteBase.ClientId; string emailSubject1 = searchPrefix + Common.GenerateResourceName(Site, "subject1"); string emailSubject2 = searchPrefix + Common.GenerateResourceName(Site, "subject2"); this.SendPlainTextEmail(null, emailSubject1, this.User1Information.UserName, this.User2Information.UserName, null); this.SendPlainTextEmail(null, emailSubject2, this.User1Information.UserName, this.User2Information.UserName, null); #endregion #region User2 move one of emails to new subfolder in Inbox folder. this.SwitchUser(this.User2Information); string emailItemOneServerID = this.GetItemServerIdFromSpecialFolder(this.User2Information.InboxCollectionId, emailSubject1); this.GetItemServerIdFromSpecialFolder(this.User2Information.InboxCollectionId, emailSubject2); TestSuiteBase.RecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject1, emailSubject2); // User2 creates one subfolder in Inbox folder. string folderID = this.CreateFolder((byte)FolderType.UserCreatedMail, Common.GenerateResourceName(Site, "FolderCreate"), this.User2Information.InboxCollectionId); TestSuiteBase.RecordCaseRelativeFolders(this.User2Information, folderID); // User2 moves the email with emailSubject1 into new subfolder. MoveItemsRequest moveItemRequest = TestSuiteBase.CreateMoveItemsRequest(emailItemOneServerID, this.User2Information.InboxCollectionId, folderID); MoveItemsResponse moveItemResponse = this.CMDAdapter.MoveItems(moveItemRequest); Site.Assert.AreEqual(3, int.Parse(moveItemResponse.ResponseData.Response[0].Status), " If MoveItems command executes successful, server should return status 3"); this.GetMailItem(folderID, emailSubject1); TestSuiteBase.RemoveRecordCaseRelativeItems(this.User2Information, this.User2Information.InboxCollectionId, emailSubject1); #endregion #region Creates Search request with DeepTraversale element Request.queryType query = new Request.queryType(); string storeName = SearchName.Mailbox.ToString(); Request.Options1 optionWithDeepTraversalAndRebuild = new Request.Options1(); // Create search request query. query.ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And }; query.Items = new Request.queryType[] { new Request.queryType() }; ((Request.queryType)query.Items[0]).ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.CollectionId, Request.ItemsChoiceType2.FreeText }; ((Request.queryType)query.Items[0]).Items = new object[] { this.User2Information.InboxCollectionId, searchPrefix }; // Create Search option with DeepTraversal and Rebuild. optionWithDeepTraversalAndRebuild.Items = new object[] { string.Empty, string.Empty }; optionWithDeepTraversalAndRebuild.ItemsElementName = new Request.ItemsChoiceType6[] { Request.ItemsChoiceType6.DeepTraversal, Request.ItemsChoiceType6.RebuildResults }; Request.SearchStore store = new Request.SearchStore { Name = storeName, Query = query, Options = optionWithDeepTraversalAndRebuild }; SearchRequest searchRequest = Common.CreateSearchRequest(new Request.SearchStore[] { store }); #endregion #region Call search command with DeepTraversal element SearchResponse searchResponse = this.CMDAdapter.Search(searchRequest); Site.Assert.AreEqual("1", searchResponse.ResponseData.Response.Store.Status, "If server successfully completed command, server should return status 1"); if (searchResponse.ResponseData.Response.Store.Status != "1" || searchResponse.ResponseData.Response.Store.Result.Length != 2) { searchResponse = this.LoopSearch(searchRequest, 2); } #endregion List<object> subjectInSearchResult = GetElementsFromSearchResponse(searchResponse, Response.ItemsChoiceType6.Subject1); bool resultContainsAllEmail = false; int findEmailCount = 0; for (int listIndex = 0; listIndex < subjectInSearchResult.Count; listIndex++) { string subject = (string)subjectInSearchResult[listIndex]; if (subject.Equals(emailSubject1) || subject.Equals(emailSubject2)) { findEmailCount++; } } if (findEmailCount == 2) { resultContainsAllEmail = true; } #region Verify Requirements MS-ASCMD_R2031, MS-ASCMD_R5856 // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R2031"); // Verify MS-ASCMD requirement: MS-ASCMD_R2031 Site.CaptureRequirementIfIsTrue( resultContainsAllEmail, 2031, @"[In CollectionId(Search)] If the DeepTraversal element (section 2.2.3.41) is present, it applies to all folders under each airsync:CollectionId element."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCMD_R5856"); // Verify MS-ASCMD requirement: MS-ASCMD_R5856 Site.CaptureRequirementIfIsTrue( resultContainsAllEmail, 5856, @"[In DeepTraversal] [The DeepTraversal element] indicates that the client wants the server to search all subfolders for the folders that are specified in the query."); #endregion }
/// <summary> /// Builds a Search request on the Mailbox store by using the specified keyword and folder collection ID /// In general, returns the XML formatted search request as follows: /// <!-- /// <?xml version="1.0" encoding="utf-8"?> /// <Search xmlns="Search" xmlns:airsync="AirSync"> /// <Store> /// <Name>Mailbox</Name> /// <Query> /// <And> /// <airsync:CollectionId>5</airsync:CollectionId> /// <FreeText>Presentation</FreeText> /// </And> /// </Query> /// <Options> /// <RebuildResults /> /// <Range>0-9</Range> /// <DeepTraversal/> /// </Options> /// </Store> /// </Search> /// --> /// </summary> /// <param name="storeName">Specify the store for which to search. Refer to [MS-ASCMD] section 2.2.3.110.2.</param> /// <param name="option">Specify a string value for which to search. Refer to [MS-ASCMD] section 2.2.3.73.</param> /// <param name="queryType">Specify the folder in which to search. Refer to [MS-ASCMD] section 2.2.3.30.4.</param> /// <returns>Returns a SearchRequest instance.</returns> internal static SearchRequest CreateSearchRequest(string storeName, Request.Options1 option, Request.queryType queryType) { Request.SearchStore searchStore = new Request.SearchStore { Name = storeName, Options = option, Query = queryType }; return(Common.CreateSearchRequest(new Request.SearchStore[] { searchStore })); }
public void MSASTASK_S03_TC01_RetrieveTaskItemWithSearch() { #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 Search command to search task on the server Request.Options1 option = new Request.Options1(); Dictionary <Request.ItemsChoiceType6, object> items = new Dictionary <Request.ItemsChoiceType6, object> { { Request.ItemsChoiceType6.DeepTraversal, string.Empty }, { Request.ItemsChoiceType6.RebuildResults, string.Empty }, { Request.ItemsChoiceType6.Range, "0-9" } }; option.Items = items.Values.ToArray <object>(); option.ItemsElementName = items.Keys.ToArray <Request.ItemsChoiceType6>(); Request.queryType queryItem = new Request.queryType { Items = new object[] { "Tasks", this.UserInformation.TasksCollectionId, subject }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.Class, Request.ItemsChoiceType2.CollectionId, Request.ItemsChoiceType2.FreeText } }; Request.queryType queryType = new Request.queryType { Items = new object[] { queryItem }, ItemsElementName = new Request.ItemsChoiceType2[] { Request.ItemsChoiceType2.And } }; SearchRequest searchRequest = TestSuiteHelper.CreateSearchRequest(SearchName.Mailbox.ToString(), option, queryType); // Search the task SearchStore searchResponse = this.TASKAdapter.Search(searchRequest); // Verify search response Site.Assert.AreNotEqual <int>(0, searchResponse.Range.Length, "The search response should be successful"); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R361"); // Verify MS-ASTASK requirement: MS-ASTASK_R361 // If the Task item in response is not null, this requirement can be captured. Site.CaptureRequirementIfIsNotNull( searchResponse.Results[0].Task, 361, @"[In Search Command Response] When a client uses the Search command request ([MS-ASCMD] section 2.2.2.14) to retrieve Task class items from the server 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)."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASTASK_R363"); // Since MS-ASTASK_R361 is captured, this requirement can be captured too. Site.CaptureRequirement( 363, @"[In Search Command Response] Top-level Task class elements, as specified in section 2.2, are returned as child elements of the search:Properties element ([MS-ASCMD] section 2.2.3.128) in the Search command response."); }