public void VisualTest() { //---------------Set up test pack------------------- var hints = new UIStyleHints(); hints.ButtonHints.MinimumHeight = 35; GlobalUIRegistry.UIStyleHints = hints; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- (new FormExceptionNotifier()).Notify(new Exception("This is a test"), "More information here", "Testing"); //---------------Test Result ----------------------- }
public void Constructor_SetsUpPropertyObjects() { //---------------Set up test pack------------------- var hints = new UIStyleHints(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- //---------------Test Result ----------------------- Assert.IsNotNull(hints.ButtonHints, "ButtonHints not set"); Assert.IsNotNull(hints.CheckBoxHints, "CheckBoxHints not set"); Assert.IsNotNull(hints.ComboBoxHints, "ComboBoxHints not set"); Assert.IsNotNull(hints.DateTimePickerHints, "DateTimePickerHints not set"); Assert.IsNotNull(hints.GridHints, "GridHints not set"); Assert.IsNotNull(hints.LabelHints, "LabelHints not set"); Assert.IsNotNull(hints.LayoutHints, "LayoutHints not set"); Assert.IsNotNull(hints.TextBoxHints, "TextBoxHints not set"); Assert.IsNotNull(hints.FormHints, "FormHints is not set"); Assert.IsNotNull(hints.StaticDataEditorManagerHints, "StaticDataEditorManagerHints is not set"); }
public void Test_WithNoBOCollection_HonoursGlobalUIHintsForButtonAutoEnabledState() { LoadMyBoDefaultClassDef(); BusinessObjectCollection<MyBO> col = new BusinessObjectCollection<MyBO>(); IReadOnlyGridControl readOnlyGridControl = CreateReadOnlyGridControl(true); var hints = new UIStyleHints(); hints.GridHints.AutoDisableEditAndDeleteWhenNoSelectedObject = true; GlobalUIRegistry.UIStyleHints = hints; readOnlyGridControl.AllowUsersToAddBO = true; readOnlyGridControl.AllowUsersToDeleteBO = true; readOnlyGridControl.AllowUsersToEditBO = true; var add = readOnlyGridControl.Buttons["Add"]; var edit = readOnlyGridControl.Buttons["Edit"]; var delete = readOnlyGridControl.Buttons["Delete"]; AddControlToForm(readOnlyGridControl); IReadOnlyGrid readOnlyGrid = readOnlyGridControl.Grid; readOnlyGrid.Columns.Add("TestProp", "TestProp"); //---------------Execute Test ---------------------- readOnlyGridControl.SetBusinessObjectCollection(col); //---------------Test Result ----------------------- Assert.AreEqual(0, readOnlyGrid.Rows.Count); Assert.IsTrue(add.Enabled, "Add button should be enabled when there are no items"); Assert.IsFalse(edit.Enabled, "Edit button should be disabled with no grid items"); Assert.IsFalse(delete.Enabled, "Delete button should be disabled with no grid items"); }
public void Test_WithBOCollection_HonoursGlobalUIHintsForButtonVisibilityANDHonorsUserAllowedCRUDOperations(bool showInactive, bool allowAdd, bool allowEdit, bool allowDelete) { //---------------Set up test pack------------------- LoadMyBoDefaultClassDef(); BusinessObjectCollection<MyBO> col = CreateCollectionWith_4_Objects(); IReadOnlyGridControl readOnlyGridControl = CreateReadOnlyGridControl(true); var hints = new UIStyleHints(); hints.GridHints.ShowDisabledOperationButtons = showInactive; GlobalUIRegistry.UIStyleHints = hints; readOnlyGridControl.AllowUsersToAddBO = allowAdd; readOnlyGridControl.AllowUsersToDeleteBO = allowDelete; readOnlyGridControl.AllowUsersToEditBO = allowEdit; var add = readOnlyGridControl.Buttons["Add"]; var edit = readOnlyGridControl.Buttons["Edit"]; var delete = readOnlyGridControl.Buttons["Delete"]; AddControlToForm(readOnlyGridControl); IReadOnlyGrid readOnlyGrid = readOnlyGridControl.Grid; readOnlyGrid.Columns.Add("TestProp", "TestProp"); //---------------Execute Test ---------------------- readOnlyGridControl.SetBusinessObjectCollection(col); //---------------Test Result ----------------------- Assert.AreEqual(4, readOnlyGrid.Rows.Count); Assert.AreEqual(add.Visible, showInactive || allowAdd, "Add button visibility not properly set for: showInactive (" + showInactive.ToString() + "), allowAdd: (" + allowAdd.ToString() + ")"); Assert.AreEqual(edit.Visible, showInactive || allowEdit, "Edit button visibility not properly set for: showInactive (" + showInactive.ToString() + "), allowEdit: (" + allowEdit.ToString() + ")"); Assert.AreEqual(delete.Visible, showInactive || allowDelete,"Delete button visibility not properly set for: showInactive (" + showInactive.ToString() + "), allowDelete: (" + allowDelete.ToString() + ")"); Assert.AreEqual(add.Enabled, allowAdd, "Add button enabled state != allowAdd"); Assert.AreEqual(edit.Enabled, allowEdit, "Edit button enabled state != allowEdit"); Assert.AreEqual(delete.Enabled, allowDelete, "Add button enabled state != allowAdd"); }