| 53 | } |
| 54 | |
| 55 | static void testMessageBuilder2(String * path) |
| 56 | { |
| 57 | printf("testMessageBuilder2\n"); |
| 58 | MessageBuilder * builder = new MessageBuilder(); |
| 59 | builder->header()->setFrom(Address::addressWithRFC822String(MCSTR("Hoà <dinh.viet.hoa@gmail.com>"))); |
| 60 | Array * to = Array::array(); |
| 61 | to->addObject(Address::addressWithRFC822String(MCSTR("Foo Bar <dinh.viet.hoa@gmail.com>"))); |
| 62 | to->addObject(Address::addressWithRFC822String(MCSTR("Other Recipient <another-foobar@to-recipient.org>"))); |
| 63 | builder->header()->setTo(to); |
| 64 | Array * cc = Array::array(); |
| 65 | cc->addObject(Address::addressWithRFC822String(MCSTR("Carbon Copy <dinh.viet.hoa@gmail.com>"))); |
| 66 | cc->addObject(Address::addressWithRFC822String(MCSTR("Other Recipient <another-foobar@to-recipient.org>"))); |
| 67 | builder->header()->setCc(cc); |
| 68 | builder->header()->setSubject(MCSTR("testMessageBuilder2")); |
| 69 | builder->header()->setDate(referenceDate()); |
| 70 | builder->header()->setMessageID(MCSTR("MyMessageID123@mail.gmail.com")); |
| 71 | builder->setHTMLBody(MCSTR("<html><body>This is a HTML content</body></html>")); |
| 72 | String * attachmentPath = path->stringByAppendingPathComponent(MCSTR("input/photo.jpg")); |
| 73 | builder->addAttachment(Attachment::attachmentWithContentsOfFile(attachmentPath)); |
| 74 | attachmentPath = path->stringByAppendingPathComponent(MCSTR("input/photo2.jpg")); |
| 75 | builder->addAttachment(Attachment::attachmentWithContentsOfFile(attachmentPath)); |
| 76 | Array * boundaries = Array::array(); |
| 77 | boundaries->addObject(MCSTR("1")); |
| 78 | boundaries->addObject(MCSTR("2")); |
| 79 | boundaries->addObject(MCSTR("3")); |
| 80 | boundaries->addObject(MCSTR("4")); |
| 81 | boundaries->addObject(MCSTR("5")); |
| 82 | builder->setBoundaries(boundaries); |
| 83 | String * outputPath = path->stringByAppendingPathComponent(MCSTR("output/builder2.eml")); |
| 84 | Data * expectedData = Data::dataWithContentsOfFile(outputPath); |
| 85 | if (!builder->data()->isEqual(expectedData)) { |
| 86 | printf("testMessageBuilder2 failed\n"); |
| 87 | fprintf(stderr, "current:\n%s\n", MCUTF8(builder->data()->stringWithCharset("utf-8"))); |
| 88 | fprintf(stderr, "expected:\n%s\n", MCUTF8(expectedData->stringWithCharset("utf-8"))); |
| 89 | global_failure ++; |
| 90 | return; |
| 91 | } |
| 92 | printf("testMessageBuilder2 ok\n"); |
| 93 | global_success ++; |
| 94 | } |
| 95 | |
| 96 | static void testMessageBuilder3(String * path) |
| 97 | { |
no test coverage detected