public void TestCreateRelProp() { IBOPropCol propCol = _propDefCol.CreateBOPropertyCol(true); IRelProp relProp = _relPropDef.CreateRelProp(propCol); Assert.AreEqual("Prop", relProp.OwnerPropertyName); Assert.AreEqual("PropName", relProp.RelatedClassPropName); }
/// <summary> /// Adds the given RelProp to the key /// </summary> /// <param name="relProp">The RelProp object to add</param> private void Add(IRelProp relProp) { if (_relProps.ContainsKey(relProp.OwnerPropertyName)) { throw new InvalidPropertyException(String.Format( "A related property with the name '{0}' is being added " + "to a collection, but already exists in the collection.", relProp.OwnerPropertyName)); } _relProps.Add(relProp.OwnerPropertyName, relProp); }
public void TestCreateRelPropNotNull() { PropDef propDef = new PropDef("Prop1", typeof(string), PropReadWriteRule.ReadWrite, "1"); RelPropDef relPropDef = new RelPropDef(propDef, "PropName1"); PropDefCol propDefCol = new PropDefCol(); propDefCol.Add(propDef); IBOPropCol propCol = propDefCol.CreateBOPropertyCol(true); IRelProp relProp = relPropDef.CreateRelProp(propCol); Assert.AreEqual(relPropDef.OwnerPropertyName, relProp.OwnerPropertyName); Assert.AreEqual(relPropDef.RelatedClassPropName, relProp.RelatedClassPropName); Assert.IsFalse(relProp.IsNull); }
public void TestCreateRelKey() { IBOPropCol propCol = mPropDefCol.CreateBOPropertyCol(true); IRelKey relKey = mRelKeyDef.CreateRelKey(propCol); Assert.IsTrue(relKey.Contains("Prop")); Assert.IsTrue(relKey.Contains("Prop2")); IRelProp relProp = relKey["Prop"]; Assert.AreEqual("Prop", relProp.OwnerPropertyName); Assert.AreEqual("PropName", relProp.RelatedClassPropName); relProp = relKey["Prop2"]; Assert.AreEqual("Prop2", relProp.OwnerPropertyName); Assert.AreEqual("PropName2", relProp.RelatedClassPropName); Assert.IsTrue(relKey.HasRelatedObject(), "This is true since the values for the properties should have defaulted to 1 each"); Assert.AreEqual("(PropName = '1') AND (PropName2 = '2')", relKey.Criteria.ToString()); }
public void TestCreateRelProp_PropDoesNotExist() { //-------------Setup Test Pack ------------------ BOPropCol propCol = new BOPropCol(); Exception exception = null; IRelProp relProp = null; //-------------Execute test --------------------- try { relProp = _relPropDef.CreateRelProp(propCol); } catch (Exception ex) { exception = ex; } //-------------Test Result ---------------------- Assert.IsNotNull(exception, "An error should have been thrown because the prop does not exist."); Assert.IsInstanceOf(typeof(InvalidPropertyNameException), exception); Assert.IsNull(relProp, "The relProp should not have been created."); }
public void Test_UpdateRelatedObject_ShouldRaiseEvent() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse(); OrganisationTestBO.LoadDefaultClassDef(); OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateUnsavedContactPerson(); ISingleRelationship relationship = (ISingleRelationship)contactPersonTestBO.Relationships["Organisation"]; bool eventCalled = false; IRelKey key = relationship.RelKey; IRelProp relProp = key[0]; relProp.PropValueUpdated += delegate { eventCalled = true; }; //---------------Assert Precondition---------------- Assert.IsTrue(contactPersonTestBO.Relationships.GetSingle <OrganisationTestBO>("Organisation").OwningBOHasForeignKey); Assert.IsFalse(eventCalled); //---------------Execute Test ---------------------- contactPersonTestBO.Organisation = organisationTestBO; //---------------Test Result ----------------------- Assert.IsTrue(eventCalled); }
/// <summary> /// Adds the given RelProp to the key /// </summary> /// <param name="relProp">The RelProp object to add</param> private void Add(IRelProp relProp) { if (_relProps.ContainsKey(relProp.OwnerPropertyName)) { throw new InvalidPropertyException(String.Format( "A related property with the name '{0}' is being added " + "to a collection, but already exists in the collection.", relProp.OwnerPropertyName)); } _relProps.Add(relProp.OwnerPropertyName, relProp); }