public async Task Should_Return_Messages_Matching_Search_Criteria() { // Setup string apiKey = ConfigurationManager.AppSettings["APIKey"]; string subjSKey = ConfigurationManager.AppSettings["UniqueExistingEmailSubject"]; // Exercise var api = new MandrillApi(apiKey); var search = new SearchRequest { Query = String.Format(@"subject:{0}", subjSKey), }; List<SearchResult> result = await api.Search(search); //Verify 2 Assert.AreEqual(1, result.Count); Assert.AreEqual(subjSKey, result[0].Subject); }
/// <summary> /// Search recently sent messages and optionally narrow by date range, tags, senders, and API keys. If no date range is specified, /// results within the last 7 days are returned. This method may be called up to 20 times per minute. If you need the data more often, /// you can use /messages/info.json to get the information for a single message, or webhooks to push activity to your own application for querying. /// <see cref="https://mandrillapp.com/api/docs/messages.JSON.html#method=search">Mandrill API Documentation</see> /// </summary> /// <param name="request">The request.</param> /// <returns>The <see cref="EmailResult"/>.</returns> public async Task<List<SearchResult>> Search(SearchRequest request) { const string path = "/messages/search.json"; var response = await Post<List<SearchResult>>(path, request); return response; }