public void Test_SelectButtonWhenClicked_ShouldApplyBusinessObjectChanges(bool enableEditing) { //---------------Set up test pack------------------- GetClassDefs(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapperSpy = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); mapperSpy.EnableEditing = enableEditing; ContactPersonTestBO contactPersonTestBo = new ContactPersonTestBO(); mapperSpy.BusinessObject = contactPersonTestBo; var expectedSelectedBO = new OrganisationTestBO(); //---------------Assert Precondition---------------- Assert.AreSame(contactPersonTestBo, mapperSpy.BusinessObject); Assert.IsNull(contactPersonTestBo.OrganisationID); //---------------Execute Test ---------------------- mapperSpy.CallSetupPopupForm(); mapperSpy.SetSelectedBusinessObject(expectedSelectedBO); mapperSpy.CallSelectClick(); //---------------Test Result ----------------------- Assert.IsNotNull(contactPersonTestBo.OrganisationID); Assert.AreSame(expectedSelectedBO, contactPersonTestBo.Organisation); }
public void Test_SetupPopupForm_WithSuperClassDef_ShouldSetUpThePopUpForm() { //--------------- Set up test pack ------------------ BusinessObjectCollection <OrganisationTestBO> organisationTestBOs = GetClassDefs(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapper = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); mapper.BusinessObject = new ContactPersonTestBO(); // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation(); //--------------- Test Preconditions ---------------- Assert.IsNull(mapper.PopupForm); //--------------- Execute Test ---------------------- //extendedTextBoxWin.Button.PerformClick(); mapper.CallSetupPopupForm(); //--------------- Test Result ----------------------- Assert.IsNotNull(mapper.PopupForm); IFormHabanero form = mapper.PopupForm; Assert.AreEqual(800, form.Width); Assert.AreEqual(600, form.Height); Assert.AreEqual(2, form.Controls.Count); Assert.AreEqual(DockStyle.Fill, form.Controls[0].Dock); Assert.IsInstanceOf(typeof(IBOGridAndEditorControl), form.Controls[0]); Assert.IsInstanceOf(typeof(BOGridAndEditorControlWin), form.Controls[0]); Assert.IsInstanceOf <IButtonGroupControl>(form.Controls[1]); IButtonGroupControl control = (IButtonGroupControl)form.Controls[1]; Assert.AreEqual("Cancel", control.Controls[0].Text); Assert.AreEqual("Select", control.Controls[1].Text); BOGridAndEditorControlWin andBOGridAndEditorControlWin = null; foreach (var ctl in form.Controls) { andBOGridAndEditorControlWin = form.Controls[0] as BOGridAndEditorControlWin; if (andBOGridAndEditorControlWin != null) { break; } } Assert.IsNotNull(andBOGridAndEditorControlWin, "Can't find BO editor on popup form"); //Assert.AreSame(mapper.BusinessObject, BOGridAndEditorControlWin.BOEditorControlWin.BusinessObject); Assert.IsTrue(andBOGridAndEditorControlWin.GridControl.IsInitialised); IBusinessObjectCollection collection = andBOGridAndEditorControlWin.GridControl.Grid.BusinessObjectCollection; Assert.IsNotNull(collection); Assert.AreEqual(organisationTestBOs.Count, collection.Count); // Assert.AreEqual(organisationTestBOs.Count, mapper.LookupList.Count); }
public void Test_CancelButton_WhenClicked_ShouldCancelEditsAndCloseForm() { //---------------Set up test pack------------------- GetClassDefs(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapper = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); mapper.BusinessObject = new ContactPersonTestBO(); mapper.CallSetupPopupForm(); //---------------Assert Precondition---------------- Assert.IsFalse(mapper.FormClosed); //---------------Execute Test ---------------------- mapper.CallCancelClick(); //---------------Test Result ----------------------- Assert.IsTrue(mapper.FormClosed); }
public void Test_SelectButtonWhenClicked_ShouldClosePopupForm() { GetClassDefs(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapperSpy = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); ContactPersonTestBO contactPersonTestBo = new ContactPersonTestBO(); mapperSpy.BusinessObject = contactPersonTestBo; //---------------Assert Precondition---------------- Assert.IsFalse(mapperSpy.FormClosed); //---------------Execute Test ---------------------- mapperSpy.CallSetupPopupForm(); mapperSpy.CallSelectClick(); //---------------Test Result ----------------------- Assert.IsTrue(mapperSpy.FormClosed); }
public void Test_ShowGridAndBOEditorControlWinOnClick() { //--------------- Set up test pack ------------------ BusinessObjectCollection <OrganisationTestBO> organisationTestBOs = CreateSavedOrganisationTestBOsCollection(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapper = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); mapper.BusinessObject = new ContactPersonTestBO(); // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation(); //--------------- Test Preconditions ---------------- Assert.IsNull(mapper.PopupForm); //--------------- Execute Test ---------------------- //extendedTextBoxWin.Button.PerformClick(); mapper.CallSetupPopupForm(); //--------------- Test Result ----------------------- Assert.IsNotNull(mapper.PopupForm); IFormHabanero form = mapper.PopupForm; Assert.AreEqual(800, form.Width); Assert.AreEqual(600, form.Height); Assert.AreEqual(2, form.Controls.Count); Assert.AreEqual(DockStyle.Fill, form.Controls[0].Dock); Assert.IsInstanceOf(typeof(IBOGridAndEditorControl), form.Controls[0]); Assert.IsInstanceOf(typeof(BOGridAndEditorControlWin), form.Controls[0]); Assert.IsInstanceOf(typeof(IButtonGroupControl), form.Controls[1]); BOGridAndEditorControlWin andBOGridAndEditorControlWin = (BOGridAndEditorControlWin)form.Controls[0]; //Assert.AreSame(mapper.BusinessObject, BOGridAndEditorControlWin.BOEditorControlWin.BusinessObject); Assert.IsTrue(andBOGridAndEditorControlWin.GridControl.IsInitialised); IBusinessObjectCollection collection = andBOGridAndEditorControlWin.GridControl.Grid.BusinessObjectCollection; Assert.IsNotNull(collection); Assert.AreEqual(organisationTestBOs.Count, collection.Count); // Assert.AreEqual(organisationTestBOs.Count, mapper.LookupList.Count); }
public void Test_SelectButtonWhenClicked_AndContactPersonNotValid_ShouldCloseWithoutError_FixBugBug541() { GetClassDefs(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapperSpy = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); ContactPersonTestBO contactPersonTestBo = new ContactPersonTestBO(); mapperSpy.BusinessObject = contactPersonTestBo; mapperSpy.SelectedBO = new OrganisationTestBO(); //---------------Assert Precondition---------------- Assert.IsFalse(mapperSpy.FormClosed); Assert.IsFalse(contactPersonTestBo.Status.IsValid()); Assert.IsTrue(mapperSpy.SelectedBO.Status.IsValid()); Assert.IsNotNull(mapperSpy.SelectedBO); //---------------Execute Test ---------------------- mapperSpy.CallSetupPopupForm(); mapperSpy.CallSelectClick(); //---------------Test Result ----------------------- Assert.IsFalse(contactPersonTestBo.Status.IsValid()); Assert.IsTrue(mapperSpy.FormClosed); }
public void Test_SetupPopupForm_WithSuperClassDef_ShouldSetUpThePopUpForm() { //--------------- Set up test pack ------------------ BusinessObjectCollection<OrganisationTestBO> organisationTestBOs = GetClassDefs(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapper = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); mapper.BusinessObject = new ContactPersonTestBO(); // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation(); //--------------- Test Preconditions ---------------- Assert.IsNull(mapper.PopupForm); //--------------- Execute Test ---------------------- //extendedTextBoxWin.Button.PerformClick(); mapper.CallSetupPopupForm(); //--------------- Test Result ----------------------- Assert.IsNotNull(mapper.PopupForm); IFormHabanero form = mapper.PopupForm; Assert.AreEqual(800, form.Width); Assert.AreEqual(600, form.Height); Assert.AreEqual(2, form.Controls.Count); Assert.AreEqual(DockStyle.Fill, form.Controls[0].Dock); Assert.IsInstanceOf(typeof(IBOGridAndEditorControl), form.Controls[0]); Assert.IsInstanceOf(typeof(BOGridAndEditorControlWin), form.Controls[0]); Assert.IsInstanceOf<IButtonGroupControl>(form.Controls[1]); IButtonGroupControl control = (IButtonGroupControl)form.Controls[1]; Assert.AreEqual("Cancel", control.Controls[0].Text); Assert.AreEqual("Select", control.Controls[1].Text); BOGridAndEditorControlWin andBOGridAndEditorControlWin = null; foreach (var ctl in form.Controls) { andBOGridAndEditorControlWin = form.Controls[0] as BOGridAndEditorControlWin; if (andBOGridAndEditorControlWin != null) break; } Assert.IsNotNull(andBOGridAndEditorControlWin, "Can't find BO editor on popup form"); //Assert.AreSame(mapper.BusinessObject, BOGridAndEditorControlWin.BOEditorControlWin.BusinessObject); Assert.IsTrue(andBOGridAndEditorControlWin.GridControl.IsInitialised); IBusinessObjectCollection collection = andBOGridAndEditorControlWin.GridControl.Grid.BusinessObjectCollection; Assert.IsNotNull(collection); Assert.AreEqual(organisationTestBOs.Count, collection.Count); // Assert.AreEqual(organisationTestBOs.Count, mapper.LookupList.Count); }
public void Test_ShowGridAndBOEditorControlWinOnClick() { //--------------- Set up test pack ------------------ BusinessObjectCollection<OrganisationTestBO> organisationTestBOs = CreateSavedOrganisationTestBOsCollection(); IControlFactory controlFactory = GetControlFactory(); ExtendedTextBoxWin extendedTextBoxWin = new ExtendedTextBoxWin(controlFactory); const string propName = "OrganisationID"; ExtendedTextBoxMapperSpy mapper = new ExtendedTextBoxMapperSpy( extendedTextBoxWin, propName, true, controlFactory); mapper.BusinessObject = new ContactPersonTestBO(); // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation(); //--------------- Test Preconditions ---------------- Assert.IsNull(mapper.PopupForm); //--------------- Execute Test ---------------------- //extendedTextBoxWin.Button.PerformClick(); mapper.CallSetupPopupForm(); //--------------- Test Result ----------------------- Assert.IsNotNull(mapper.PopupForm); IFormHabanero form = mapper.PopupForm; Assert.AreEqual(800, form.Width); Assert.AreEqual(600, form.Height); Assert.AreEqual(2, form.Controls.Count); Assert.AreEqual(DockStyle.Fill, form.Controls[0].Dock); Assert.IsInstanceOf(typeof(IBOGridAndEditorControl), form.Controls[0]); Assert.IsInstanceOf(typeof(BOGridAndEditorControlWin), form.Controls[0]); Assert.IsInstanceOf(typeof(IButtonGroupControl), form.Controls[1]); BOGridAndEditorControlWin andBOGridAndEditorControlWin = (BOGridAndEditorControlWin)form.Controls[0]; //Assert.AreSame(mapper.BusinessObject, BOGridAndEditorControlWin.BOEditorControlWin.BusinessObject); Assert.IsTrue(andBOGridAndEditorControlWin.GridControl.IsInitialised); IBusinessObjectCollection collection = andBOGridAndEditorControlWin.GridControl.Grid.BusinessObjectCollection; Assert.IsNotNull(collection); Assert.AreEqual(organisationTestBOs.Count, collection.Count); // Assert.AreEqual(organisationTestBOs.Count, mapper.LookupList.Count); }