Beispiel #1
0
        /// <summary>
        /// Edits the given object
        /// </summary>
        /// <param name="obj">The object to edit</param>
        /// <param name="uiDefName">The name of the set of ui definitions
        /// used to design the edit form. Setting this to an empty string
        /// will use a ui definition with no name attribute specified.</param>
        /// <param name="postEditAction">Action to be performed when the editing is completed or cancelled. Typically used if you want to update
        /// a grid or a list in an asynchronous environment (E.g. to select the recently edited item in the grid)</param>
        /// <returns>Returs true if edited successfully of false if the edits
        /// were cancelled</returns>
        public virtual bool EditObject(IBusinessObject obj, string uiDefName, PostObjectEditDelegate postEditAction)
        {
            BusinessObject       bo   = (BusinessObject)obj;
            IDefaultBOEditorForm form = CreateEditorForm(bo, uiDefName, postEditAction);

            return(form.ShowDialog());
        }
Beispiel #2
0
        public virtual void Test_CloseForm_ShouldCallPostEditDelegateWithCancelled()
        {
            //---------------Set up test pack-------------------
            IBusinessObject bo = _classDefMyBo.CreateNewBusinessObject();

            bool                 delegateCalled = false;
            bool                 cancelledValue = false;
            IBusinessObject      boInDelegate   = null;
            IDefaultBOEditorForm boEditorForm   =
                GetControlFactory().CreateBOEditorForm((BusinessObject)bo, "default",
                                                       delegate(IBusinessObject bo1, bool cancelled)
            {
                delegateCalled = true;
                cancelledValue = cancelled;
                boInDelegate   = bo1;
            });

            ShowFormIfNecessary(boEditorForm);
            EditControlValueOnForm(_defaultBOEditorForm, "TestProp", "TestValue");
            EditControlValueOnForm(_defaultBOEditorForm, "TestProp2", "TestValue2");
            //--------------Assert PreConditions----------------
            Assert.IsFalse(delegateCalled);
            //---------------Execute Test ----------------------
            boEditorForm.Close();
            //---------------Test Result -----------------------
            Assert.IsTrue(delegateCalled);
            Assert.IsTrue(cancelledValue);
            Assert.AreSame(bo, boInDelegate);
        }
Beispiel #3
0
        /// <summary>
        /// Edits the given business object by providing a form in which the
        /// user can edit the data
        /// </summary>
        /// <param name="obj">The business object to edit</param>
        /// <param name="uiDefName">The name of the set of ui definitions
        /// used to design the edit form. Setting this to an empty string
        /// will use a ui definition with no name attribute specified.</param>
        /// <returns>Returs true if the user chose to save the edits or
        /// false if the user cancelled the edits</returns>
        public virtual bool EditObject(IBusinessObject obj, string uiDefName)
        {
            BusinessObject       bo   = (BusinessObject)obj;
            IDefaultBOEditorForm form = CreateEditorForm(bo, uiDefName);

            return(form.ShowDialog());
        }
Beispiel #4
0
        public void Test_ClickCancel_WhenNotIsNew_ShouldCancelEditsAndNotMarkForDelete()
        {
            //---------------Set up test pack-------------------
            IBusinessObject bo = _classDefMyBo.CreateNewBusinessObject();

            bo.Save();
            IDefaultBOEditorForm boEditorForm = GetControlFactory()
                                                .CreateBOEditorForm((BusinessObject)bo, "default", () => null);

            ShowFormIfNecessary(boEditorForm);
            EditControlValueOnForm(boEditorForm, "TestProp", "TestValue");
            EditControlValueOnForm(boEditorForm, "TestProp2", "TestValue2");
            bo.SetPropertyValue("TestProp", "TestValue");
            IButton cancelButton = boEditorForm.Buttons["Cancel"];

            //--------------Assert PreConditions----------------
            Assert.IsNotNull(cancelButton);
            Assert.IsTrue(bo.Status.IsDirty, "BO should be dirty prior to cancelling");
            //---------------Execute Test ----------------------
            cancelButton.PerformClick();
            //---------------Test Result -----------------------
            Assert.AreEqual(DialogResult.Cancel, boEditorForm.DialogResult);
            Assert.AreEqual(null, bo.GetPropertyValue("TestProp"));
            Assert.AreEqual(null, bo.GetPropertyValue("TestProp2"));
            Assert.IsFalse(bo.Status.IsDirty, "BO should not be dirty after cancelling");
            Assert.IsFalse(bo.Status.IsDeleted, "Saved BO should not be deleted on cancelling edits");
            Assert.IsNull(boEditorForm.PanelInfo.BusinessObject);
        }
Beispiel #5
0
        public void Test_ClickOK_ShouldCallDelegateWithCorrectInformation()
        {
            //---------------Set up test pack-------------------
            IBusinessObject bo = _classDefMyBo.CreateNewBusinessObject();

            bool                 delegateCalled = false;
            bool                 cancelledValue = true;
            IBusinessObject      boInDelegate   = null;
            IDefaultBOEditorForm boEditorForm   = GetControlFactory()
                                                  .CreateBOEditorForm((BusinessObject)bo, "default",
                                                                      delegate(IBusinessObject bo1, bool cancelled)
            {
                delegateCalled = true;
                cancelledValue = cancelled;
                boInDelegate   = bo1;
            });

            ShowFormIfNecessary(boEditorForm);
            IButton okButton = boEditorForm.Buttons["OK"];

            //--------------Assert PreConditions----------------
            Assert.IsNotNull(okButton);
            Assert.IsFalse(delegateCalled);
            //---------------Execute Test ----------------------
            okButton.PerformClick();
            //---------------Test Result -----------------------
            Assert.IsTrue(delegateCalled);
            Assert.IsFalse(cancelledValue);
            Assert.AreSame(bo, boInDelegate);
        }
Beispiel #6
0
        public void Test_AlternateConstruct_2_ShouldConstructWithDefaultConstructor()
        {
            //---------------Set up test pack-------------------
            IBusinessObject bo = _classDefMyBo.CreateNewBusinessObject();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IDefaultBOEditorForm defaultBOEditorForm = GetControlFactory().CreateBOEditorForm((BusinessObject)bo, "default", () => null);

            //---------------Test Result -----------------------
            Assert.IsNotNull(defaultBOEditorForm.PanelInfo);
            Assert.IsNotNull(defaultBOEditorForm.GroupControlCreator);
        }
Beispiel #7
0
        public void Test_Constructor_WithGroupCreator()
        {
            //---------------Set up test pack-------------------
            IBusinessObject     bo           = _classDefMyBo.CreateNewBusinessObject();
            GroupControlCreator groupControl = GetControlFactory().CreateCollapsiblePanelGroupControl;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IDefaultBOEditorForm defaultBOEditorForm = GetControlFactory().CreateBOEditorForm((BusinessObject)bo, "default", groupControl);

            //---------------Test Result -----------------------
            Assert.IsNotNull(defaultBOEditorForm.PanelInfo);
            Assert.IsNotNull(defaultBOEditorForm.GroupControlCreator);
            Assert.AreSame(groupControl, defaultBOEditorForm.GroupControlCreator);
        }
Beispiel #8
0
        public void Test_Constructor_WhenUIDefIsInherited_ShouldUseInheritedUIDef()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef       = Entity.LoadDefaultClassDef();
            IClassDef subClassDef    = LegalEntity.LoadClassDef_WithSingleTableInheritance();
            IClassDef subSubClassDef = Vehicle.LoadClassDef_WithClassTableInheritance();
            UIForm    uiForm         = new UIForm(new UIFormTab(new UIFormColumn(new UIFormField("My Form Field", "EntityType"))));
            string    uiDefName      = "EntityUiDef";

            classDef.UIDefCol.Add(new UIDef(uiDefName, uiForm, null));
            IBusinessObject businessObject = subSubClassDef.CreateNewBusinessObject();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IDefaultBOEditorForm defaultBOEditorForm = GetControlFactory().CreateBOEditorForm((BusinessObject)businessObject, uiDefName);
            //---------------Test Result -----------------------
            IPanelInfo panelInfo = defaultBOEditorForm.PanelInfo;

            Assert.IsNotNull(panelInfo);
            Assert.AreSame(uiForm, panelInfo.UIForm);
        }
Beispiel #9
0
 public void SetupTest()
 {
     BusinessObjectManager.Instance.ClearLoadedObjects();
     _bo = _classDefMyBo.CreateNewBusinessObject();
     _defaultBOEditorForm = CreateDefaultBOEditorForm(_bo);
 }
Beispiel #10
0
 private static void EditControlValueOnForm(IDefaultBOEditorForm defaultBOEditorForm, string propertyName, string value)
 {
     defaultBOEditorForm.PanelInfo.FieldInfos[propertyName].ControlMapper.Control.Text = value;
 }
 public void SetupTest()
 {
     BusinessObjectManager.Instance.ClearLoadedObjects();
     _bo = _classDefMyBo.CreateNewBusinessObject();
     _defaultBOEditorForm = CreateDefaultBOEditorForm(_bo);
 }
 private static void EditControlValueOnForm(IDefaultBOEditorForm defaultBOEditorForm, string propertyName, string value)
 {
     defaultBOEditorForm.PanelInfo.FieldInfos[propertyName].ControlMapper.Control.Text = value;
 }