public void TestStrategy_CorrectButtonStatus_ForInitialEmptyGrid() { //---------------Set up test pack------------------- IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_WithStrategy(); IButton cancelButton = gridWithPanelControl.Buttons["Cancel"]; IButton deleteButton = gridWithPanelControl.Buttons["Delete"]; IButton saveButton = gridWithPanelControl.Buttons["Save"]; IButton newButton = gridWithPanelControl.Buttons["New"]; //---------------Assert Precondition---------------- Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows.Count); Assert.IsFalse(saveButton.Enabled); Assert.IsFalse(newButton.Enabled); Assert.IsFalse(deleteButton.Enabled); Assert.IsFalse(cancelButton.Enabled); //---------------Execute Test ---------------------- gridWithPanelControl.SetBusinessObjectCollection(new BusinessObjectCollection <MyBO>()); //---------------Test Result ----------------------- Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows.Count); Assert.IsFalse(saveButton.Enabled); Assert.IsTrue(newButton.Enabled); Assert.IsFalse(deleteButton.Enabled); Assert.IsFalse(cancelButton.Enabled); }
public void TestStrategy_CorrectButtonStatus_WhenGridCleared() { //---------------Set up test pack------------------- BusinessObjectCollection <MyBO> myBOs = CreateSavedMyBoCollection(); IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_WithStrategy(); gridWithPanelControl.SetBusinessObjectCollection(myBOs); IButton cancelButton = gridWithPanelControl.Buttons["Cancel"]; IButton deleteButton = gridWithPanelControl.Buttons["Delete"]; IButton saveButton = gridWithPanelControl.Buttons["Save"]; IButton newButton = gridWithPanelControl.Buttons["New"]; //---------------Assert Precondition---------------- Assert.AreEqual(2, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows.Count); Assert.IsTrue(saveButton.Enabled); Assert.IsTrue(newButton.Enabled); Assert.IsTrue(deleteButton.Enabled); Assert.IsTrue(cancelButton.Enabled); //---------------Execute Test ---------------------- deleteButton.PerformClick(); deleteButton.PerformClick(); //---------------Test Result ----------------------- Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows.Count); Assert.IsFalse(saveButton.Enabled); Assert.IsTrue(newButton.Enabled); Assert.IsFalse(deleteButton.Enabled); Assert.IsFalse(cancelButton.Enabled); }
public void TestCancelButton_BOAndControlsAreSynchronised() { //---------------Set up test pack------------------- BusinessObjectCollection <MyBO> myBOs = CreateSavedMyBoCollection(); IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_WithStrategy(); gridWithPanelControl.SetBusinessObjectCollection(myBOs); IButton cancelButton = gridWithPanelControl.Buttons["Cancel"]; MyBO firstBO = myBOs[0]; string originalValue = firstBO.TestProp; string newValue = BOTestUtils.RandomString; PanelInfo.FieldInfo testPropFieldInfo = ((IBusinessObjectPanel)gridWithPanelControl.BusinessObjectControl).PanelInfo.FieldInfos["TestProp"]; testPropFieldInfo.ControlMapper.Control.Text = newValue; //---------------Assert Precondition---------------- Assert.IsFalse(firstBO.Status.IsNew); Assert.IsFalse(firstBO.Status.IsDirty); Assert.AreNotEqual(originalValue, newValue); Assert.AreNotEqual(newValue, firstBO.TestProp); //vwg doesn't synchronise by default //---------------Execute Test ---------------------- cancelButton.PerformClick(); //---------------Test Result ----------------------- Assert.IsFalse(firstBO.Status.IsNew); Assert.IsFalse(firstBO.Status.IsDirty); Assert.AreEqual(originalValue, firstBO.TestProp); Assert.AreEqual(originalValue, testPropFieldInfo.ControlMapper.Control.Text); }
public void TestCancelButton_RestoreChangesGridText() { //---------------Set up test pack------------------- BusinessObjectCollection <MyBO> myBOs = CreateSavedMyBoCollection(); IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_NoStrategy(); gridWithPanelControl.SetBusinessObjectCollection(myBOs); IButton cancelButton = gridWithPanelControl.Buttons["Cancel"]; MyBO currentBO = gridWithPanelControl.CurrentBusinessObject; string originalValue = currentBO.TestProp; string newValue = BOTestUtils.RandomString; currentBO.TestProp = newValue; //---------------Assert Precondition---------------- Assert.AreNotEqual(originalValue, newValue); Assert.AreEqual(newValue, currentBO.TestProp); //---------------Execute Test ---------------------- cancelButton.PerformClick(); //---------------Test Result ----------------------- Assert.AreEqual(originalValue, currentBO.TestProp); Assert.AreEqual(originalValue, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows[0].Cells["TestProp"].Value); Assert.AreSame(currentBO, gridWithPanelControl.CurrentBusinessObject); }
public void TestGridRowChange_DoesNotChangeWhenBOInvalid() { //---------------Set up test pack------------------- IClassDef classDef = ClassDef.Get <MyBO>(); classDef.PropDefcol["TestProp"].Compulsory = true; BusinessObjectCollection <MyBO> myBOs = CreateSavedMyBoCollection(); IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_WithStrategy(); gridWithPanelControl.SetBusinessObjectCollection(myBOs); MyBO firstBO = myBOs[0]; MyBO secondBO = myBOs[1]; firstBO.TestProp = ""; //---------------Assert Precondition---------------- Assert.IsFalse(firstBO.Status.IsNew); Assert.IsFalse(firstBO.Status.IsValid()); Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index); Assert.AreSame(firstBO, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedBusinessObject); //---------------Execute Test ---------------------- gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedBusinessObject = secondBO; //gridWithPanelControl.ReadOnlyGridControl.Grid.CurrentCell = // gridWithPanelControl.ReadOnlyGridControl.Grid.Rows[1].Cells[1]; //---------------Test Result ----------------------- Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index); Assert.AreSame(firstBO, gridWithPanelControl.ReadOnlyGridControl.Grid.SelectedBusinessObject); Assert.IsTrue(firstBO.Status.IsDirty); }
public void TestSaveButton_UpdatesGridText() { //---------------Set up test pack------------------- BusinessObjectCollection <MyBO> myBOs = CreateSavedMyBoCollection(); IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_WithStrategy(); gridWithPanelControl.SetBusinessObjectCollection(myBOs); IButton saveButton = gridWithPanelControl.Buttons["Save"]; MyBO currentBO = gridWithPanelControl.CurrentBusinessObject; string originalValue = currentBO.TestProp; string newValue = BOTestUtils.RandomString; PanelInfo.FieldInfo testPropFieldInfo = ((IBusinessObjectPanel)gridWithPanelControl.BusinessObjectControl).PanelInfo.FieldInfos["TestProp"]; testPropFieldInfo.ControlMapper.Control.Text = newValue; //---------------Assert Precondition---------------- Assert.AreNotEqual(originalValue, newValue); Assert.AreEqual(originalValue, currentBO.TestProp); Assert.AreEqual(originalValue, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows[0].Cells["TestProp"].Value); //---------------Execute Test ---------------------- saveButton.PerformClick(); //---------------Test Result ----------------------- Assert.AreEqual(newValue, currentBO.TestProp); Assert.AreEqual(newValue, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows[0].Cells["TestProp"].Value); Assert.AreSame(currentBO, gridWithPanelControl.CurrentBusinessObject); }
public void TestStrategy_DeleteButton_RemovesNewBO() { //---------------Set up test pack------------------- IGridWithPanelControl <MyBO> gridWithPanelControl = CreateGridAndBOEditorControl_WithStrategy(); gridWithPanelControl.SetBusinessObjectCollection(new BusinessObjectCollection <MyBO>()); IButton deleteButton = gridWithPanelControl.Buttons["Delete"]; IButton newButton = gridWithPanelControl.Buttons["New"]; newButton.PerformClick(); MyBO currentBO = gridWithPanelControl.CurrentBusinessObject; //---------------Assert Precondition---------------- Assert.IsTrue(deleteButton.Enabled); Assert.IsTrue(currentBO.Status.IsNew); Assert.AreEqual(1, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows.Count); //---------------Execute Test ---------------------- deleteButton.PerformClick(); //---------------Test Result ----------------------- Assert.AreEqual(0, gridWithPanelControl.ReadOnlyGridControl.Grid.Rows.Count); }
private static void AssertSelectedBusinessObject(MyBO myBO, IGridWithPanelControl<MyBO> gridWithPanelControl) { Assert.AreSame(myBO, gridWithPanelControl.ReadOnlyGridControl.SelectedBusinessObject); Assert.AreSame(myBO, gridWithPanelControl.BusinessObjectControl.BusinessObject, "Selected BO in Grid should be loaded in the BoControl"); Assert.AreSame(myBO, gridWithPanelControl.CurrentBusinessObject); }
///<summary> /// Constructor for <see cref="GridWithPanelControlStrategyVWG{TBusinessObject}"/> ///</summary> ///<param name="gridWithPanelControl"></param> public GridWithPanelControlStrategyVWG(IGridWithPanelControl <TBusinessObject> gridWithPanelControl) { _gridWithPanelControl = gridWithPanelControl; }
///<summary> /// Constructor for the <see cref="GridWithPanelControlManager{TBusinessObject}"/> ///</summary> ///<param name="gridWithPanelControl"></param> ///<param name="controlFactory"></param> ///<param name="businessObjectControl"></param> ///<param name="uiDefName"></param> public GridWithPanelControlManager(IGridWithPanelControl <TBusinessObject> gridWithPanelControl, IControlFactory controlFactory, IBusinessObjectControl businessObjectControl, string uiDefName) { _gridWithPanelControl = gridWithPanelControl; SetupControl(controlFactory, businessObjectControl, uiDefName); }