public async Task CanGet() { // Arrange Message message = (await _messageService.ListByLabelAsync(Label.Sent)).First(); string threadId = message.ThreadId; // Act MessageThread thread = await _service.GetAsync(threadId); // Assert thread.Should().NotBeNull(); thread.Id.Should().NotBeNullOrWhiteSpace(); //thread.Snippet.ShouldNotBeNullOrEmpty(); }
/// <summary> /// Lists the threads in the specified label. /// </summary> /// <param name="service">Gmail API service instance</param> /// <param name="labelId">Only return threads with the specified label ID</param> /// <param name="query">Only return threads matching the specified query. /// Supports the same query format as the Gmail search box. For example, "from:[email protected] rfc822msgid: is:unread".</param> /// <param name="maxResults">Maximum number of threads to return</param> /// <param name="includeSpamAndTrash">Include threads from SPAM and TRASH in the results.</param> /// <returns>A list of threads</returns> public static async Task <IList <MessageThread> > ListByLabelAsync(this ThreadService service, string labelId, string query = null, ushort maxResults = 0, bool includeSpamAndTrash = false) { var threadList = await service.ListIdsAsync(query, maxResults, includeSpamAndTrash, labelId); var tasks = threadList.Threads.Select(id => service.GetAsync(id.Id)); return((await Task.WhenAll(tasks)).ToList()); }