| 94 | } |
| 95 | |
| 96 | static void testMessageBuilder3(String * path) |
| 97 | { |
| 98 | printf("testMessageBuilder3\n"); |
| 99 | MessageBuilder * builder = new MessageBuilder(); |
| 100 | builder->header()->setFrom(Address::addressWithRFC822String(MCSTR("Hoà <dinh.viet.hoa@gmail.com>"))); |
| 101 | Array * to = Array::array(); |
| 102 | to->addObject(Address::addressWithRFC822String(MCSTR("Foo Bar <dinh.viet.hoa@gmail.com>"))); |
| 103 | to->addObject(Address::addressWithRFC822String(MCSTR("Other Recipient <another-foobar@to-recipient.org>"))); |
| 104 | builder->header()->setTo(to); |
| 105 | Array * cc = Array::array(); |
| 106 | cc->addObject(Address::addressWithRFC822String(MCSTR("Carbon Copy <dinh.viet.hoa@gmail.com>"))); |
| 107 | cc->addObject(Address::addressWithRFC822String(MCSTR("Other Recipient <another-foobar@to-recipient.org>"))); |
| 108 | builder->header()->setCc(cc); |
| 109 | builder->header()->setSubject(MCSTR("testMessageBuilder3")); |
| 110 | builder->header()->setDate(referenceDate()); |
| 111 | builder->header()->setMessageID(MCSTR("MyMessageID123@mail.gmail.com")); |
| 112 | builder->setHTMLBody(MCSTR("<html><body><div>This is a HTML content</div><div><img src=\"cid:123\"></div></body></html>")); |
| 113 | String * attachmentPath = path->stringByAppendingPathComponent(MCSTR("input/photo.jpg")); |
| 114 | builder->addAttachment(Attachment::attachmentWithContentsOfFile(attachmentPath)); |
| 115 | attachmentPath = path->stringByAppendingPathComponent(MCSTR("input/photo2.jpg")); |
| 116 | Attachment * attachment = Attachment::attachmentWithContentsOfFile(attachmentPath); |
| 117 | attachment->setContentID(MCSTR("123")); |
| 118 | builder->addRelatedAttachment(attachment); |
| 119 | Array * boundaries = Array::array(); |
| 120 | boundaries->addObject(MCSTR("1")); |
| 121 | boundaries->addObject(MCSTR("2")); |
| 122 | boundaries->addObject(MCSTR("3")); |
| 123 | boundaries->addObject(MCSTR("4")); |
| 124 | boundaries->addObject(MCSTR("5")); |
| 125 | builder->setBoundaries(boundaries); |
| 126 | String * outputPath = path->stringByAppendingPathComponent(MCSTR("output/builder3.eml")); |
| 127 | Data * expectedData = Data::dataWithContentsOfFile(outputPath); |
| 128 | if (!builder->data()->isEqual(expectedData)) { |
| 129 | printf("testMessageBuilder3 failed\n"); |
| 130 | fprintf(stderr, "current:\n%s\n", MCUTF8(builder->data()->stringWithCharset("utf-8"))); |
| 131 | fprintf(stderr, "expected:\n%s\n", MCUTF8(expectedData->stringWithCharset("utf-8"))); |
| 132 | global_failure ++; |
| 133 | return; |
| 134 | } |
| 135 | printf("testMessageBuilder3 ok\n"); |
| 136 | global_success ++; |
| 137 | } |
| 138 | |
| 139 | static Array * pathsInDirectory(String * directory) |
| 140 | { |
no test coverage detected