• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Deleting ManagedObject with no undo... (fails testing)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Distributed Objects and Bonjour
  • Next by Date: Re: Changing file & directory names
  • Previous by thread: Re: Distributed Objects and Bonjour
  • Next by thread: Re: NSLog() and stderr
  • Index(es):
    • Date
    • Thread