• 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
Re: WOUnitTest for relations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOUnitTest for relations


  • Subject: Re: WOUnitTest for relations
  • From: Christian Pekeler <email@hidden>
  • Date: Sat, 13 May 2006 10:00:57 -0600

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@hidden)
Help/Unsubscribe/Update your Subscription:
40pekeler.org


This email sent to email@hidden


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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >WOUnitTest for relations (From: Wolfram Stebel <email@hidden>)

  • Prev by Date: Re: WOUnitTest pattern?
  • Next by Date: Re: WOUnitTest pattern?
  • Previous by thread: WOUnitTest for relations
  • Next by thread: Faulting problem.
  • Index(es):
    • Date
    • Thread