protected static GetCustomClassDef ( ) : IClassDef | ||
Résultat | IClassDef |
public void TestConstructor_DefaultUIDef_NoControlFactory() { //---------------Set up test pack------------------- IClassDef def = TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); //---------------Assert Precondition---------------- Assert.IsNotNull(GlobalUIRegistry.ControlFactory); //---------------Execute Test ---------------------- IBOPanelEditorControl controlWin = CreateEditorControl(def); //---------------Test Result ----------------------- Assert.IsNotNull(controlWin); AssertControlsAreDisabled(controlWin); }
public void Test_setBusinessObject_ChangesBOInBOControl() { // ---------------Set up test pack------------------- GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); IBOPanelEditorControl controlWin = CreateEditorControl(TestBOEditorControl.GetCustomClassDef()); OrganisationTestBO businessObject = OrganisationTestBO.CreateSavedOrganisation(); //---------------Assert Precondition---------------- Assert.IsNull(controlWin.BusinessObject); // ---------------Execute Test ---------------------- controlWin.BusinessObject = businessObject; // ---------------Test Result ----------------------- Assert.AreEqual(businessObject, controlWin.BusinessObject); Assert.AreSame(businessObject, controlWin.PanelInfo.BusinessObject); AssertControlsAreEnabled(controlWin); }
public virtual void Test_IsDirty_WhenNoEditsDone_ShouldBeFalse() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson(); IBOPanelEditorControl controlWin = CreateEditorControl(person.ClassDef); //---------------Assert Precondition---------------- Assert.IsTrue(person.Status.IsValid()); //---------------Execute Test ---------------------- controlWin.BusinessObject = person; bool dirty = controlWin.IsDirty; //---------------Test Result ----------------------- Assert.IsFalse(dirty); }
public virtual void Test_HasErrors_WhenBOValid_ShouldBeFalse() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson(); IBOPanelEditorControl controlWin = CreateEditorControl(person.ClassDef); controlWin.BusinessObject = person; //---------------Assert Precondition---------------- Assert.IsTrue(controlWin.BusinessObject.Status.IsValid()); //---------------Execute Test ---------------------- bool hasErrors = controlWin.HasErrors; //---------------Test Result ----------------------- Assert.IsFalse(hasErrors); }
public virtual void Test_IfValidState_WhenSetControlValueToInvalidValue_ShouldUpdatesErrorProviders() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson(); IBOPanelEditorControl controlWin = CreateEditorControl(person.ClassDef); controlWin.BusinessObject = person; //---------------Assert Precondition---------------- Assert.IsTrue(controlWin.BusinessObject.Status.IsValid()); AssertErrorProvidersHaveBeenCleared(controlWin); //---------------Execute Test ---------------------- SetSurnameTextBoxToNull(controlWin); //---------------Test Result ----------------------- AssertErrorProviderHasErrors(controlWin, "Surname"); }
public virtual void TestConstructor_NullClassDef_ShouldRaiseError() { // ---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); // ---------------Assert Precondition---------------- // ---------------Execute Test ---------------------- try { CreateEditorControl(GetControlFactory(), null, TestBOEditorControl.CUSTOM_UIDEF_NAME); Assert.Fail("Null controlFactory should be prevented"); } // ---------------Test Result ----------------------- catch (ArgumentNullException ex) { Assert.AreEqual("classDef", ex.ParamName); } }
public void Test_IfInvalidState_WhenSetBOToNull_ShouldClearErrorProviders() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO boInvalid = ContactPersonTestBO.CreateUnsavedContactPerson("", ""); IBOPanelEditorControl controlWin = CreateEditorControl(boInvalid.ClassDef); controlWin.BusinessObject = boInvalid; //---------------Assert Precondition---------------- Assert.IsFalse(boInvalid.Status.IsValid()); AssertErrorProviderHasErrors(controlWin, "Surname"); //---------------Execute Test ---------------------- controlWin.BusinessObject = null; //---------------Test Result ----------------------- Assert.IsNull(controlWin.BusinessObject); AssertErrorProvidersHaveBeenCleared(controlWin); }
public void Test_SetBusinessObject_Null() { // ---------------Set up test pack------------------- GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); IBOPanelEditorControl controlWin = CreateEditorControl(TestBOEditorControl.GetCustomClassDef()); OrganisationTestBO businessObject = OrganisationTestBO.CreateSavedOrganisation(); controlWin.BusinessObject = businessObject; //---------------Assert Precondition---------------- Assert.IsNotNull(controlWin.BusinessObject); // ---------------Execute Test ---------------------- controlWin.BusinessObject = null; // ---------------Test Result ----------------------- Assert.IsNull(controlWin.BusinessObject); AssertControlsAreDisabled(controlWin); controlWin.PanelInfo.ClearErrorProviders(); AssertErrorProvidersHaveBeenCleared(controlWin); }
public virtual void Test_ApplyChangesToBo_WhenControlIsEdited_ShouldUpdateTheBusinessObject() { //---------------Set up test pack------------------- TestBOEditorControl.GetCustomClassDef(); GlobalUIRegistry.ControlFactory = GetControlFactory(); BORegistry.DataAccessor = new DataAccessorInMemory(); ContactPersonTestBO person = ContactPersonTestBO.CreateSavedContactPerson(); IBOPanelEditorControl controlWin = CreateEditorControl(person.ClassDef); controlWin.BusinessObject = person; //---------------Assert Precondition---------------- Assert.IsTrue(controlWin.BusinessObject.Status.IsValid()); Assert.IsFalse(controlWin.IsDirty); TestUtil.AssertStringNotEmpty(person.Surname, "person.Surname"); //---------------Execute Test ---------------------- SetSurnameTextBoxToNull(controlWin); controlWin.ApplyChangesToBusinessObject(); //---------------Test Result ----------------------- TestUtil.AssertStringEmpty(person.Surname, "person.Surname"); }
public virtual void TestConstructor_uiDefDoesNotHaveAUIForm_ShouldRaiseError() { // ---------------Set up test pack------------------- IClassDef def = TestBOEditorControl.GetCustomClassDef(); // ---------------Assert Precondition---------------- // ---------------Execute Test ---------------------- try { CreateEditorControl(GetControlFactory(), def, TestBOEditorControl.GRID_WITHNOFORM); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroDeveloperException ex) { string expectedDeveloperMessage = "The 'IBOEditorControl"; StringAssert.Contains(expectedDeveloperMessage, ex.Message); expectedDeveloperMessage = "' could not be created since the the uiDef '" + TestBOEditorControl.GRID_WITHNOFORM + "' does not exist in the classDef for '" + def.ClassNameFull; StringAssert.Contains(expectedDeveloperMessage, ex.Message); } }