Deleting ManagedObject with no undo... (fails testing)
Deleting ManagedObject with no undo... (fails testing)
- Subject: Deleting ManagedObject with no undo... (fails testing)
- From: email@hidden
- Date: Sat, 1 Jul 2006 10:57:42 -0700
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@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden