Exemple #1
0
 RequestContext CreateContext()
 {
     RequestContext context = new RequestContext();
     this.AddTextSources(context);
     this.AddMailSources(context);
     return context;
 }
Exemple #2
0
 void AddMailSources(RequestContext context)
 {    
     foreach (KeyValuePair<string, MailAddress> kv in DocumentSourcesMailAddress)
     {
         Assert.DoesNotThrow(() => context.Add(new DocumentSource(kv.Key, kv.Value)));
     }
 }
Exemple #3
0
        public void TestBlueBluttonSerialization()
        {            
            RequestContext context = this.CreateContext();
            
            MimeEntity entity = null;
            Assert.DoesNotThrow(() => entity = context.ToMimeEntity());
            
            string entityText = null;            
            Assert.DoesNotThrow(() => entityText = entity.ToString());
            
            MimeEntity parsedEntity = null;
            Assert.DoesNotThrow(() => parsedEntity = MimeSerializer.Default.Deserialize<MimeEntity>(entityText));

            Attachment attachment = null;
            Assert.DoesNotThrow(() => attachment = context.ToAttachment());
            Assert.True(attachment.ContentType.MediaType == MediaTypeNames.Text.Plain);
            Assert.True(attachment.ContentDisposition.FileName == RequestContext.AttachmentName);
            
            string attachmentBody = attachment.StringContent();
            Assert.True(attachmentBody.Contains(RequestContext.FieldNames.DocumentSource));
            
            RequestContext contextParsed = new RequestContext(parsedEntity.Body.Text);
            this.Compare(context.GetDocumentSources(), contextParsed.GetDocumentSources());
        }