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_WhenSetInvalidPropertyValue_ShouldUpdateItemInComboToBlank() { //---------------Set up test pack------------------- IComboBox cmbox = CreateComboBox(); BusinessObjectCollection <OrganisationTestBO> boCol; RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol); OrganisationTestBO organisationTestBO = boCol[0]; string origToString = organisationTestBO.ToString(); Guid newToString = Guid.NewGuid(); ContactPersonTestBO person = CreateCPWithRelatedOrganisation(organisationTestBO); mapper.BusinessObject = person; //---------------Assert precondition---------------- Assert.AreEqual(organisationTestBO.ToString(), origToString); Assert.AreEqual(origToString.ToString(), cmbox.Text); //---------------Execute Test ---------------------- person.OrganisationID = newToString; //---------------Test Result ----------------------- Assert.AreNotEqual(origToString, newToString); Assert.AreEqual("", cmbox.Text); }
public override void Test_KeyPressEventUpdatesBusinessObject_WithoutCallingApplyChanges() { //---------------Set up test pack------------------- IComboBox cmbox = CreateComboBox(); BusinessObjectCollection <OrganisationTestBO> boCol; RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol); OrganisationTestBO newBO = boCol.CreateBusinessObject(); newBO.Save(); OrganisationTestBO organisationTestBO = boCol[0]; ContactPersonTestBO person = CreateCPWithRelatedOrganisation(organisationTestBO); mapper.BusinessObject = person; //---------------Execute Test ---------------------- cmbox.Text = newBO.ToString(); //---------------Test Result ----------------------- Assert.AreSame(newBO, person.Organisation, "For Windows the value should be changed."); }
public void Test_LoadSingleBO_NoChildren() { //---------------Set up test pack------------------- TreeViewWin treeView = new TreeViewWin(); TreeViewController treeViewController = new TreeViewController(treeView); OrganisationTestBO organisationTestBO = new OrganisationTestBO(); //-------------Assert Preconditions ------------- Assert.AreEqual(0, treeView.Nodes.Count); //---------------Execute Test ---------------------- treeViewController.LoadTreeView(organisationTestBO); //---------------Test Result ----------------------- Assert.AreEqual(1, treeView.Nodes.Count); ITreeNode node = treeView.Nodes[0]; Assert.AreEqual(organisationTestBO.ToString(), node.Text); Assert.AreEqual(0, node.Nodes.Count); }
public void Test_LoadSingleBO_OneChildRelationship_Expanded() { //---------------Set up test pack------------------- TreeViewWin treeView = new TreeViewWin(); TreeViewController treeViewController = new TreeViewController(treeView); OrganisationTestBO organisationTestBO = new OrganisationTestBO(); //-------------Assert Preconditions ------------- Assert.AreEqual(0, treeView.Nodes.Count); //---------------Execute Test ---------------------- treeViewController.LoadTreeView(organisationTestBO, 1); //---------------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); }
public virtual void Test_KeyPressStrategy_UpdatesBusinessObject_WhenEnterKeyPressed() { //---------------Set up test pack------------------- ComboBoxWinStub cmbox = new ComboBoxWinStub(); BusinessObjectCollection <OrganisationTestBO> boCol; RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol); mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy(); OrganisationTestBO newBO = boCol.CreateBusinessObject(); OrganisationTestBO organisationTestBO = boCol[0]; ContactPersonTestBO person = CreateCPWithRelatedOrganisation(organisationTestBO); mapper.BusinessObject = person; cmbox.Text = newBO.ToString(); //---------------Assert Precondition---------------- Assert.AreNotSame(newBO, person.Organisation, "For Windows the value should be changed."); //---------------Execute Test ---------------------- cmbox.CallSendKeyBob(); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy); Assert.AreSame(newBO, person.Organisation, "For Windows the value should be changed."); }