示例#1
0
        /// <summary>
        /// Lists the drafts in the user's inbox.
        /// </summary>
        /// <param name="service">Gmail API service instance</param>
        /// <returns>A list of Drafts</returns>
        public static async Task <IList <Draft> > ListAsync(this DraftService service)
        {
            DraftList draftIds = await service.ListIdsAsync();

            var tasks = draftIds.Drafts.Select(async draft => (await service.GetAsync(draft.Id)));

            return((await Task.WhenAll(tasks)).ToList());
        }
        public async Task CanGet()
        {
            // Arrange
            Draft draft        = Samples.DraftSample;
            Draft createdDraft = await _helper.CreateAsync(draft);

            Draft getDraft = null;

            // Act
            Func <Task> action = async() => getDraft = await _service.GetAsync(createdDraft.Id);

            // Assert
            action.ShouldNotThrow();
            getDraft.Id.Should().Be(createdDraft.Id);
        }