by Steven31 » 22 Jul 2011, 01:45
Im trying to mock a NSFilemanager with ARC enabled however i can't get the mock to not throw an exception for the following lines
- Code: Select all
- (void)testFileCopiedIntoDocumentsDir
{
id mockManager = [OCMockObject mockForClass:[NSFileManager class]];
// the following two lines are what are causing problems
NSError *error = (__bridge NSError *)[OCMArg anyPointer];
[[mockManager expect] copyItemAtURL:[OCMArg any] toURL:[OCMArg any] error:&error];
BOOL success = [fileImporter importFileAtURL:src withFileManger:mockManager];
STAssertEquals(YES, success, @"The file should return that it has been successfully imported");
[mockManager verify];
}
// implementation of importFileAtURL:withFileManager:
- (BOOL)importFileAtURL:(NSURL *)url withFileManger:(NSFileManager *)fileManger
{
NSURL *toURL = [self createDocumentURLfromSrcURL:url];
NSError *error = nil;
[fileManger copyItemAtURL:url toURL:toURL error:&error];
if (error)
{
return NO;
}
return YES;
}
- (NSURL *)createDocumentURLfromSrcURL:(NSURL *)srcURL
{
NSURL *destURL = [[myMusicStandAppDelegate sharedInstance] applicationDocumentsDirectory];
return [destURL URLByAppendingPathComponent:[srcURL lastPathComponent] isDirectory:NO];
}