public void Test_NonAutoLoading_SetPerson_WithUnsavedOrganisation_ShouldNotRemoveOrganisation_FIXBUG() { //---------------Set up test pack------------------- ComboBoxWinStub cmbox = new ComboBoxWinStub(); BusinessObjectCollection <OrganisationTestBO> boCol; RelationshipComboBoxMapper mapper = new RelationshipComboBoxMapper(cmbox, "Organisation", false, GlobalUIRegistry.ControlFactory); boCol = GetBoColWithOneItem(); mapper.BusinessObjectCollection = boCol; mapper.BusinessObject = new ContactPersonTestBO(); OrganisationTestBO testBO = new OrganisationTestBO(); ContactPersonTestBO person = CreateCPWithRelatedOrganisation(testBO); //---------------Assert Precondition---------------- Assert.False(boCol.Contains(testBO)); Assert.AreSame(testBO, person.Organisation); Assert.IsNotNull(person.Organisation); Assert.IsTrue(person.Organisation.Status.IsNew); //---------------Execute Test ---------------------- mapper.BusinessObject = person; //---------------Test Result ----------------------- Assert.IsNotNull(person.Organisation); }
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_WhenChangePropValue_ShouldUpdateControlValue_WithoutCallingUpdateControlValue() { //---------------Set up test pack------------------- IComboBox cmbox = CreateComboBox(); BusinessObjectCollection <OrganisationTestBO> boCol; RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol); OrganisationTestBO newBO = boCol.CreateBusinessObject(); OrganisationTestBO organisationTestBO = boCol[0]; ContactPersonTestBO person = CreateCPWithRelatedOrganisation(organisationTestBO); mapper.BusinessObject = person; //---------------Assert precondition---------------- Assert.AreSame(organisationTestBO, person.Organisation); Assert.AreSame(organisationTestBO, cmbox.SelectedItem); //---------------Execute Test ---------------------- person.Organisation = newBO; //---------------Test Result ----------------------- Assert.AreSame(newBO, person.Organisation); Assert.AreSame(newBO, cmbox.SelectedItem, "Value is not set after changing bo relationship"); }
public void Test_SetSelectedItem_WhenAnItemIsSelectedAndRelatedBusnessObjectWasNull_ShouldUpdateBusinessObjectWithSelectedValue() { //---------------Set up test pack------------------- IComboBox cmbox = CreateComboBox(); BusinessObjectCollection <OrganisationTestBO> boCol; RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol); var newOrganisation = boCol.CreateBusinessObject(); newOrganisation.Save(); ContactPersonTestBO person = new ContactPersonTestBO(); mapper.BusinessObject = person; //---------------Assert Precondition---------------- Assert.IsNull(person.Organisation); //---------------Execute Test ---------------------- cmbox.SelectedItem = newOrganisation; //---------------Test Result ----------------------- Assert.AreSame(newOrganisation, cmbox.SelectedItem); Assert.AreSame(newOrganisation, person.Organisation); }
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 void Test_KeyPressStrategy_DoesNotUpdateBusinessObject_SelectedIndexChanged() { //---------------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; //---------------Execute Test ---------------------- cmbox.SelectedItem = newBO; //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy); Assert.AreNotSame(newBO, person.Organisation, "For Windows the value should be changed."); Assert.AreSame(organisationTestBO, person.Organisation, "For Windows the value should be changed."); }
public override 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(); newBO.Save(); 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."); }