public void Test_BusinessObject_WhenSet_HavingExistingNonSingleRelationshipOnRelatedBO_ShouldThrowError()
{
//---------------Set up test pack-------------------
ClassDef.ClassDefs.Clear();
AddressTestBO.LoadDefaultClassDef();
IClassDef contactPersonClassDef = ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated();
ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
const string innerRelationshipName = "ContactPersonTestBO";
const string outerRelationshipName = "Addresses";
const string relationshipName = outerRelationshipName + "." + innerRelationshipName;
BORelationshipMapper boRelationshipMapper = new BORelationshipMapper(relationshipName);
//---------------Assert Precondition----------------
Assert.IsNull(boRelationshipMapper.BusinessObject);
Assert.IsNull(boRelationshipMapper.Relationship);
//---------------Execute Test ----------------------
try
{
boRelationshipMapper.BusinessObject = contactPersonTestBO;
Assert.Fail("Expected to throw a HabaneroDeveloperException");
}
//---------------Test Result -----------------------
catch (HabaneroDeveloperException ex)
{
StringAssert.Contains("The relationship '" + outerRelationshipName + "' on '"
+ contactPersonClassDef.ClassName + "' is not a Single Relationship. Please contact your system administrator.", ex.Message);
StringAssert.Contains("The relationship '" + outerRelationshipName + "' on the BusinessObject '"
+ contactPersonClassDef.ClassNameFull + "' is not a Single Relationship therefore cannot be traversed.", ex.DeveloperMessage);
Assert.IsNull(boRelationshipMapper.BusinessObject);
Assert.IsNull(boRelationshipMapper.Relationship);
}
}