FROM : listposter
DATE : Sat Jul 01 19:57:42 2006
Hi,
I'm in the testing phase of my framework, and one of my methods used
to delete an NSMangedObject without undo (used for certain
circumstances) fails its test when it asks the deleted object if its
deleted via isDeleted.....
My method is as folows:
- (void)deleteSelfWithoutUndoRegistration
{
NSManagedObjectContext *theContext = [self managedObjectContext];
NSUndoManager *theUndoManager = [theContext undoManager];
[theContext processPendingChanges];
[theUndoManager disableUndoRegistration];
[theContext deleteObject:self];
[theContext processPendingChanges];
[theUndoManager enableUndoRegistration];
}
And the test for it is:
- (void)
test__NSManagedObjectAdditionsTests___deleteSelfWithoutUndoRegistration
{
NSUndoManager *contextUndoManager = [testContext undoManager];
STAssertNotNil(contextUndoManager,nil);
NSManagedObject *aManagedObject = (NSManagedObject *)
[NSEntityDescription insertNewObjectForEntityForName:@"Test_Entity"
inManagedObjectContext: testContext];
STAssertNotNil(aManagedObject,nil);
unsigned undoLevelsBefore = [contextUndoManager levelsOfUndo];
[aManagedObject deleteSelfWithoutUndoRegistration];
unsigned undoLevelsAfter = [contextUndoManager levelsOfUndo];
STAssertTrue([aManagedObject isDeleted],nil); //TEST FAILS HERE
STAssertEquals(undoLevelsBefore,undoLevelsAfter,nil);
}
The testing NSManagedObjectContext is set up to be an in-memory store
with a nil URL/Options/etc. Is there anything I can do about this?
Commenting out the undo registration methods cause isDeleted to
return YES, therefore turning off undo registration causes it to
return NO... whats up with that?
Any clue?
Andre
<email_removed>
DATE : Sat Jul 01 19:57:42 2006
Hi,
I'm in the testing phase of my framework, and one of my methods used
to delete an NSMangedObject without undo (used for certain
circumstances) fails its test when it asks the deleted object if its
deleted via isDeleted.....
My method is as folows:
- (void)deleteSelfWithoutUndoRegistration
{
NSManagedObjectContext *theContext = [self managedObjectContext];
NSUndoManager *theUndoManager = [theContext undoManager];
[theContext processPendingChanges];
[theUndoManager disableUndoRegistration];
[theContext deleteObject:self];
[theContext processPendingChanges];
[theUndoManager enableUndoRegistration];
}
And the test for it is:
- (void)
test__NSManagedObjectAdditionsTests___deleteSelfWithoutUndoRegistration
{
NSUndoManager *contextUndoManager = [testContext undoManager];
STAssertNotNil(contextUndoManager,nil);
NSManagedObject *aManagedObject = (NSManagedObject *)
[NSEntityDescription insertNewObjectForEntityForName:@"Test_Entity"
inManagedObjectContext: testContext];
STAssertNotNil(aManagedObject,nil);
unsigned undoLevelsBefore = [contextUndoManager levelsOfUndo];
[aManagedObject deleteSelfWithoutUndoRegistration];
unsigned undoLevelsAfter = [contextUndoManager levelsOfUndo];
STAssertTrue([aManagedObject isDeleted],nil); //TEST FAILS HERE
STAssertEquals(undoLevelsBefore,undoLevelsAfter,nil);
}
The testing NSManagedObjectContext is set up to be an in-memory store
with a nil URL/Options/etc. Is there anything I can do about this?
Commenting out the undo registration methods cause isDeleted to
return YES, therefore turning off undo registration causes it to
return NO... whats up with that?
Any clue?
Andre
<email_removed>
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

