//Relationship //-- should this reference the reverse relationship if exists // (i.e. bidirectional navigatable relationship). //-- /// <summary> /// Adds a business object to the collection /// </summary> /// <param name="bo">The business object to add</param> protected override bool AddInternal(TBusinessObject bo) { var boColInternal = ((IBusinessObjectCollectionInternal)this); if (!boColInternal.Loading) { if (!this._relationship.RelKey.Criteria.IsMatch(bo, false)) { MultipleRelationshipDef def = this._relationship.RelationshipDef as MultipleRelationshipDef; if (def != null) { def.CheckCanAddChild(bo); } } } if (!base.AddInternal(bo)) { return(false); } if (boColInternal.Loading) { return(true); } if (IsForeignKeySetup(bo)) { return(true); } SetUpForeignKey(bo); SetupRelatedObject(bo); return(true); }
public void Test_CheckCanAdd_NullObject() { //---------------Set up test pack------------------- MultipleRelationshipDef relDef = new MultipleRelationshipDef ("rel", typeof(MyRelatedBo), new RelKeyDef(), true, "", DeleteParentAction.Prevent); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { relDef.CheckCanAddChild(null); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroDeveloperException ex) { StringAssert.Contains("could not be added since the business object is null", ex.Message); } //---------------Test Result ----------------------- }