Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Deleting ManagedObject with no undo... (fails testing)



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.