//[Fact]
        public async Task NonExistingAttachment_ReturnsNotFound()
        {
            // Arrange
            Draft   draft     = new Draft();// TODO: create draft with attachment
            Message message   = (await _draftService.CreateAsync(draft)).Message;
            string  messageId = message.Id;

            // Act
            Func <Task> action = async() => await _service.GetAsync(messageId, Guid.NewGuid().ToString("N"));

            // Assert
            var ex = await Assert.ThrowsAsync <GmailException>(action);

            ex.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }
示例#2
0
        /// <summary>
        /// Create a draft.
        /// </summary>
        /// <param name="service">Gmail API service instance</param>
        /// <param name="subject">The subject of the draft</param>
        /// <param name="body">The body of the draft</param>
        /// <returns></returns>
        public static async Task <Draft> CreateAsync(this DraftService service, string subject, string body)
        {
            Draft draftInput = new Draft
            {
                Message = new Message
                {
                    Snippet  = subject,
                    PlainRaw = body.ToBase64UrlString(),//TODO: HTML headers
                    Payload  =
                    {
                        Headers              = { new Header {
                                                     Name = "Content-Type", Value = "text/html"
                                                 } },
                        MimeType             = "text/html"
                    }
                }
            };

            return(await service.CreateAsync(draftInput));
        }