-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CancelEdits not cleaning up related object references #59
Comments
Hi @peter-wiles I logged a Habanero issue yesterday that I need to resolve quite quickly for IUA. Issue: #59 Scenario: This scenario fails on the Final step. Basically, what is happening is that when you call CancelEdits the properties are set back to what they were but the related object’s relationship back to the cancelled object does not remove the object. I have reproduced it with a test, but there are a few ways I can go to resolve this:
What do you think? My current failing test is this ( on TestBusinessObject): [Test]
public void Test_CancelEdit_ShouldCleanupRelationships_BUGFIX_GitHub59()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();
orgClassDef.RelationshipDefCol["ContactPeople"].TimeOut = 10000;
ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
var organisation = OrganisationTestBO.CreateSavedOrganisation();
organisation.Save();
var contactPerson = ContactPersonTestBO.CreateUnsavedContactPerson("Contact", "Person");
contactPerson.Organisation = organisation;
var relationshipBackToBo = (MultipleRelationship<ContactPersonTestBO>)organisation.Relationships["ContactPeople"];
//---------------Assert Precondition----------------
Assert.IsTrue(contactPerson.Status.IsNew);
Assert.IsTrue(contactPerson.Status.IsDirty);
Assert.IsTrue(contactPerson.Status.IsEditing);
Assert.That(relationshipBackToBo.BusinessObjectCollection, Contains.Item(contactPerson));
//---------------Execute Test ----------------------
contactPerson.CancelEdits();
//---------------Test Result -----------------------
Assert.That(relationshipBackToBo.BusinessObjectCollection, Is.Empty);
} |
Hi Mark, I think I prefer the event handler approach, it seems cleaner than special code in the CancelEdits, will probably handle more cases and sounds fairly simple. I'm not able to look in depth at the code at the moment but out of the two options I like that more. I do agree that a change in the fk prop (which is thus a change in the related object itself) should make the relationship dirty. I don't think this is too dangerous, but I can see why you're worried. I think that change would be ok to make. Not sure what should happen for a one-to-one relationship though. Peter From: markwhitfeldmailto:[email protected] Hi @peter-wileshttps://github.com/peter-wiles I logged a Habanero issue yesterday that I need to resolve quite quickly for IUA. Scenario: This scenario fails on the Final step. Basically, what is happening is that when you call CancelEdits the properties are set back to what they were but the related object’s relationship back to the cancelled object does not remove the object. I have reproduced it with a test, but there are a few ways I can go to resolve this:
What do you think? My current failing test is this ( on TestBusinessObject):
— |
Scenario:
Given I have a new Item with a specified existing ItemType
So, the Item now exists in the ItemType.Items relationship collection
When I cancel edits on the new Item object
Then the Item should no longer exist in the ItemType.Items relstionship collection
This scenario fails on the Final step.
The text was updated successfully, but these errors were encountered: