Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MIME/CoreAttachment tests get files from bundle

Because in the newest simulators, your current working directory is more like it is in when you're on the phone itself.

Also no need for the filePrefix var any longer.
  • Loading branch information...
commit 7565fd2e462571ac8ff02a4d5d34d9e06d219029 1 parent d28da84
Scott Nonnenberg scottnonnenberg authored
16 Tests/CTCoreAttachmentTests.m
View
@@ -34,32 +34,32 @@
@implementation CTCoreAttachmentTests
- (void)testJPEG {
- NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6201.jpg"];
- CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6201" ofType:@"jpg"];
+ CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
STAssertEqualObjects(@"image/jpeg", [attach contentType], @"The content-type should have been image/jpeg");
STAssertTrue([attach data] != nil, @"Data should not have been nil");
[attach release];
}
- (void)testPNG {
- NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6202.png"];
- CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6202" ofType:@"png"];
+ CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
STAssertEqualObjects(@"image/png", [attach contentType], @"The content-type should have been image/png");
STAssertTrue([attach data] != nil, @"Data should not have been nil");
[attach release];
}
- (void)testTIFF {
- NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6193.tif"];
- CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6193" ofType:@"tif"];
+ CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
STAssertEqualObjects(@"image/tiff", [attach contentType], @"The content-type should have been image/TIFF");
STAssertTrue([attach data] != nil, @"Data should not have been nil");
[attach release];
}
- (void)testNEF {
- NSString *path = [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/DSC_6204.NEF"];
- CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:path];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/DSC_6204" ofType:@"NEF"];
+ CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithContentsOfFile:filePath];
STAssertEqualObjects(@"application/octet-stream", [attach contentType],
@"The content-type should have been application/octet-stream");
STAssertTrue([attach data] != nil, @"Data should not have been nil");
2  Tests/CTMIMETests.h
View
@@ -31,8 +31,6 @@
#import <SenTestingKit/SenTestingKit.h>
-const NSString *filePrefix;
-
@interface CTMIMETests : SenTestCase {
}
23 Tests/CTMIMETests.m
View
@@ -41,11 +41,10 @@
#import "CTMIME_TextPart.h"
#import "CTMIME_Enumerator.h"
-const NSString *filePrefix = @"/Users/mronge/Projects/MailCore/";
-
@implementation CTMIMETests
- (void)testMIMETextPart {
- CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab"]];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/kiwi-dev/1167196014.6158_0.theronge.com:2,Sab" ofType:@""];
+ CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
STAssertTrue([mime isKindOfClass:[CTMIME_MessagePart class]],@"Outmost MIME type should be Message but it's not!");
STAssertTrue([[mime content] isKindOfClass:[CTMIME_MultiPart class]],@"Incorrect MIME structure found!");
@@ -85,7 +84,9 @@ - (void)testBruteForce {
while ((file = [dirEnumerator nextObject])) {
if (!NSEqualRanges([file rangeOfString:@".svn"],notFound))
continue;
- CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@TestData/kiwi-dev/%@",filePrefix,file]];
+
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:[NSString stringWithFormat:@"TestData/kiwi-dev/%@",file] ofType:@""];
+ CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
NSLog(@"%@", [msg subject]);
[msg fetchBodyStructure];
NSString *stuff = [msg body];
@@ -95,7 +96,9 @@ - (void)testBruteForce {
}
- (void)testImageJPEGAttachment {
- CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:[NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/mime-tests/imagetest"]];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/mime-tests/imagetest" ofType:@""];
+ CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
+
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
STAssertTrue([mime isKindOfClass:[CTMIME_MessagePart class]],@"Outmost MIME type should be Message but it's not!");
STAssertTrue([[mime content] isKindOfClass:[CTMIME_MultiPart class]],@"Incorrect MIME structure found!");
@@ -111,8 +114,9 @@ - (void)testImageJPEGAttachment {
}
- (void)testImagePNGAttachment {
- CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:
- [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/mime-tests/png_attachment"]];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/mime-tests/png_attachment" ofType:@""];
+ CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
+
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:
[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
STAssertTrue([mime isKindOfClass:[CTMIME_MessagePart class]],
@@ -133,8 +137,9 @@ - (void)testImagePNGAttachment {
}
- (void)testEnumerator {
- CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:
- [NSString stringWithFormat:@"%@%@",filePrefix,@"TestData/mime-tests/png_attachment"]];
+ NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/mime-tests/png_attachment" ofType:@""];
+ CTCoreMessage *msg = [[CTCoreMessage alloc] initWithFileAtPath:filePath];
+
CTMIME *mime = [CTMIMEFactory createMIMEWithMIMEStruct:
[msg messageStruct]->msg_mime forMessage:[msg messageStruct]];
CTMIME_Enumerator *enumerator = [mime mimeEnumerator];
Please sign in to comment.
Something went wrong with that request. Please try again.