public void testPersonDeletesManadant() {
Person person = (Person)mockEditingContext ().createSavedObject("Person"); CMandant mandant = (CMandant)mockEditingContext ().createSavedObject("CMandant"); person.addObjectToBothSidesOfRelationshipWithKey(mandant, "mandanten");
        mockEditingContext().deleteObject(person);
        mockEditingContext().saveChanges();
assertFalse(mockEditingContext().registeredObjects ().containsObject(person)); assertFalse(mockEditingContext().registeredObjects ().containsObject(mandant));
}

Christian



On May 13, 2006, at 9:21, Wolfram Stebel wrote:

Hi again,

i try to create an object hierarchy in the test editing context.
the factory methods below set up the relations as required.
then i delete the root object from the ec. I want to see, that the delete
rule "cascade" realy does a cascaded delete!

i thought, i could test the remaining content like shown below in method
assertEditingContextRemovedInserted.

After creation there are 3 objects in ec.insertedObjects.
After deletion of "aPerson" there are 2 still objects in ec.insertedObjects.

This means, cascaded deletes are applied not earlier than on saveChanges?

How could i test the cascaded delete correct?

TIA

Wolfram

--------------


Code sample that creates the hierarchy:


...

EOEditingContext ec = this.editingContext ();   // from WOUTTestCase

CMandant m = CMandant.getMandantForAlias ( this.editingContext (),
NSProperties.getProperty ( "DefaultMandant", "pappnase" ) );

CPerson c = ( CPerson ) m.creator();

CPerson aPerson = CPerson.newPersonForMandantAndPerson ( ec, m, c );

CAddress theAddress =
CAddress.newAddressForMandantAndBusinesPartnerAndPerson ( ec, m, aPerson, c
);

CTelecom theTelecom =
CTelecom.newTelecomForMandantAndBusinesPartnerAndPerson ( ec, m, aPerson, c
);

// ec.saveChanges ();
ec.deleteObject ( aPerson );
// ec.saveChanges ();
// all objects should be deleted via delete rule
this.assertEditingContextRemovedInserted ();

...



public void assertEditingContextRemovedInserted ()
{
    // test if content is unchanged, i.e. added eos and removed eos
->unchanged
NSSet inserted = new NSSet ( editingContext().insertedObjects () );
    NSSet deleted = new NSSet ( editingContext().deletedObjects () );
    NSSet remaining = inserted.setBySubtractingSet ( deleted );
    try
    {
        assertTrue ( remaining.count () == 0 );
    }
    catch ( Exception exception )
    {
        fail ( "not all inserted objects are removed : " +
exception.getMessage() );
    }
}


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/christian% 40pekeler.org

This email sent to [EMAIL PROTECTED]


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to