public void Test_LoadSingleBO_OneChild_Expanded() { //---------------Set up test pack------------------- TreeViewWin treeView = new TreeViewWin(); TreeViewController treeViewController = new TreeViewController(treeView); OrganisationTestBO organisationTestBO = new OrganisationTestBO { Name = TestUtil.GetRandomString() }; ContactPersonTestBO contactPersonTestBO = organisationTestBO.ContactPeople.CreateBusinessObject(); contactPersonTestBO.Surname = TestUtil.GetRandomString(); //-------------Assert Preconditions ------------- Assert.AreEqual(0, treeView.Nodes.Count); //---------------Execute Test ---------------------- treeViewController.LoadTreeView(organisationTestBO, 2); //---------------Test Result ----------------------- Assert.AreEqual(1, treeView.Nodes.Count); ITreeNode node = treeView.Nodes[0]; Assert.AreEqual(organisationTestBO.ToString(), node.Text); Assert.AreEqual(1, node.Nodes.Count); ITreeNode relationshipNode = node.Nodes[0]; Assert.AreEqual("ContactPeople", relationshipNode.Text); Assert.AreEqual(1, relationshipNode.Nodes.Count); ITreeNode childNode = relationshipNode.Nodes[0]; Assert.AreEqual(contactPersonTestBO.ToString(), childNode.Text); }
public void Test_WhenSetThePropertyToABusinessObject_ShouldSetThePrimaryKey() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); var classDef = MyBO.LoadClassDefWithBOLookup(); ContactPersonTestBO.LoadDefaultClassDef(); var cp = new ContactPersonTestBO(); const string expectedSurname = "abc"; cp.Surname = expectedSurname; var myBO = (BusinessObject)classDef.CreateNewBusinessObject(); //---------------Assert Precondition---------------- Assert.AreEqual(expectedSurname, cp.ToString()); //---------------Execute Test ---------------------- myBO.SetPropertyValue("TestProp2", cp); //---------------Test Result ----------------------- Assert.AreEqual(cp.ContactPersonID, myBO.GetPropertyValue("TestProp2"), "This is the ID of the related object"); Assert.AreEqual(expectedSurname, myBO.GetPropertyValueToDisplay("TestProp2"), "This is the ToString of the related object"); }
//TODO Mark 07 Aug 2009: NNB Review this - I don't think that this is the action you want because it could have side effects when creating a new BO public virtual void Test_AddBOToCol_WhenNullOrEmptyToString_ShouldRaiseError() { //---------------Set up test pack------------------- IComboBox cmbox = CreateComboBox(); RelationshipComboBoxMapper mapper1 = GetMapper(cmbox); BusinessObjectCollection<ContactPersonTestBO> boCol = new BusinessObjectCollection<ContactPersonTestBO> { new ContactPersonTestBO() }; mapper1.BusinessObjectCollection = boCol; RelationshipComboBoxMapper mapper = mapper1; ContactPersonTestBO newBO = new ContactPersonTestBO { Surname = "" }; //---------------Assert Precondition---------------- Assert.AreEqual(1, boCol.Count); Assert.AreEqual(2, mapper.Control.Items.Count); Assert.IsNull(newBO.ToString()); //---------------Execute Test ---------------------- try { boCol.Add(newBO); Assert.Fail("expected HabaneroDeveloperException"); } //---------------Test Result ----------------------- catch (HabaneroDeveloperException ex) { string message = string.Format("Cannot add a business object of type '{0}' " + "to the 'ComboBoxCollectionSelector' if its ToString is null or zero length" , newBO.ClassDef.ClassName); StringAssert.Contains(message, ex.Message); } }