public void TestLoadingRelatedObjectWithSingleTableInheritance()
        {
            //---------------Set up test pack-------------------
            DatabaseConnection.CurrentConnection.ExecuteRawSql(
                "delete from filledcircle_table; delete from circle_table; delete from shape_table");
            //MyBO has a relationship to Shape. Shape potentially has a circle for single table inheritance.
            MyBO.LoadClassDefWithShape_SingleTableInheritance_Relationship();

            MyBO bo = new MyBO();
            CircleNoPrimaryKey circle = new CircleNoPrimaryKey();

            circle.Radius    = 5;
            circle.ShapeName = "MyShape";
            circle.Save();
            bo.SetPropertyValue("ShapeID", circle.ShapeID);
            bo.Save();

            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Execute Test ----------------------
            bo = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <MyBO>(bo.ID);
            Shape shape = bo.Shape;

            //---------------Test Result -----------------------
            Assert.AreSame(typeof(CircleNoPrimaryKey), shape.GetType());
            Assert.IsFalse(shape.Status.IsNew);
            Assert.IsFalse(shape.Status.IsDeleted);
            Assert.IsFalse(shape.Status.IsEditing);
            Assert.IsFalse(shape.Status.IsDirty);
            Assert.IsTrue(shape.Status.IsValid());
        }
Exemplo n.º 2
0
        public override void Test_SetDateToGridCustomFormat_LoadViaCollection()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadClassDefWithDateTime();
            IDataGridViewColumn             column;
            const string                    requiredFormat = "dd.MMM.yyyy";
            IGridBase                       gridBase       = CreateGridBaseWithDateCustomFormatCol(out column, requiredFormat);
            BusinessObjectCollection <MyBO> col            = new BusinessObjectCollection <MyBO>();
            MyBO         bo           = new MyBO();
            const string dateTimeProp = "TestDateTime";
            DateTime     expectedDate = DateTime.Now;

            bo.SetPropertyValue(dateTimeProp, expectedDate);
            col.Add(bo);
            //--------------Assert PreConditions----------------
            Assert.AreEqual(expectedDate, bo.GetPropertyValue(dateTimeProp));
            Assert.AreEqual(1, gridBase.ColumnCount);
            Assert.AreEqual(dateTimeProp, gridBase.Columns[0].Name);
            Assert.AreEqual(dateTimeProp, gridBase.Columns[0].DataPropertyName);
            //---------------Execute Test ----------------------
            gridBase.BusinessObjectCollection = col;
            //---------------Test Result -----------------------
            IDataGridViewCell dataGridViewCell = gridBase.Rows[0].Cells[0];

            Assert.AreEqual(expectedDate.ToString(requiredFormat), dataGridViewCell.FormattedValue);
        }
Exemplo n.º 3
0
        public void TestEditItemFromCollectionUpdatesItemInSelector()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            IBusinessObjectCollection col;
            IBOColSelectorControl     boColSelector = GetSelectorWith_4_Rows(out col);
            const string propName = "TestProp";
            const int    rowIndex = 1;
            MyBO         bo       = (MyBO)col[rowIndex];

            boColSelector.BusinessObjectCollection = col;
            string origStringValue = ((IBOComboBoxSelector)boColSelector).GetItemText(bo);

            //---------------Verify precondition----------------
            Assert.AreEqual(bo.ToString(), origStringValue);
            //---------------Execute Test ----------------------
            const string newPropValue = "NewValue";

            bo.SetPropertyValue(propName, newPropValue);
            bo.Save();
            //---------------Test Result -----------------------
            string newStringValue = ((IBOComboBoxSelector)boColSelector).GetItemText(bo);

            Assert.AreNotEqual(origStringValue, newStringValue);
            Assert.AreEqual(newPropValue + " - " + bo.MyBoID, newStringValue);
        }
Exemplo n.º 4
0
        public void Test_BOPropUpdated_WhenBONotInComboBox_ShouldNotRaiseError_FixBug()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            IBusinessObjectCollection col;
            IBOColSelectorControl     boColSelector = GetSelectorWith_4_Rows(out col);
            const string propName = "TestProp";
            const int    rowIndex = 1;
            MyBO         bo       = (MyBO)col[rowIndex];

            boColSelector.BusinessObjectCollection = col;
            IBOComboBoxSelector selector = ((IBOComboBoxSelector)boColSelector);
            string origStringValue       = selector.GetItemText(bo);

            selector.ComboBox.Items.Remove(bo);
            //---------------Assert Precondition----------------
            Assert.AreEqual(bo.ToString(), origStringValue);
            Assert.AreEqual(4, selector.ComboBox.Items.Count);
            //---------------Execute Test ----------------------
            const string newPropValue = "NewValue";

            bo.SetPropertyValue(propName, newPropValue);
            bo.Save();
            //---------------Test Result -----------------------
            string newBoItemText = selector.GetItemText(bo);

            Assert.AreNotEqual(origStringValue, newBoItemText);
            Assert.AreEqual(newPropValue + " - " + bo.MyBoID, newBoItemText);
        }
Exemplo n.º 5
0
        public void TestVWGRowIsRefreshed()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IGridBase    gridBase = GetGridBaseWith_4_Rows(out col);
            const string propName = "TestProp";
            const int    rowIndex = 1;
            MyBO         bo       = col[rowIndex];

            AddControlToForm(gridBase);

            //---------------verify preconditions---------------
            object cellValue = GetCellValue(rowIndex, gridBase, propName);

            //DataGridViewCell cell;

            Assert.AreEqual(bo.GetPropertyValue(propName), cellValue);

            //---------------Execute Test ----------------------
            bo.SetPropertyValue(propName, "UpdatedValue");
            bo.Save();
            //---------------Test Result -----------------------
            //gridBase.SelectedBusinessObject = bo;

            //cell = GetCell(rowIndex, propName, gridBase);
            cellValue = GetCellValue(rowIndex, gridBase, propName);
            Assert.AreEqual("UpdatedValue", cellValue);
        }
Exemplo n.º 6
0
        public void Test_GetPropertyValueToDisplay_SimpleLookup()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef = MyBO.LoadClassDefWithSimpleIntegerLookup();
            MyBO bo1 = (MyBO)_itsClassDef.CreateNewBusinessObject();

            bo1.SetPropertyValue("TestProp2", "Text");
            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("Text", mapper.GetPropertyValueToDisplay("TestProp2"));
        }
        public void TestAddRow_UpdatesCollection()
        {
            BusinessObjectCollection <MyBO> col = null;
            IDataSetProvider dataSetProvider    = GetDataSetProviderWithCollection(ref col);
            BOMapper         mapper             = new BOMapper(col.ClassDef.CreateNewBusinessObject());
            DataTable        table = dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);
            MyBO             boNew = new MyBO();

            boNew.SetPropertyValue("TestProp", "bo3prop1");
            boNew.SetPropertyValue("TestProp2", "s2");
            //---------------Assert Precondition----------------
            Assert.AreEqual(4, table.Rows.Count);
            Assert.AreEqual(4, col.Count);
            Assert.AreEqual(4, col.CreatedBusinessObjects.Count);
            //---------------Execute Test ----------------------
            table.Rows.Add(new object[] { null, "bo3prop1", "bo3prop2" });
            //---------------Test Result -----------------------
            Assert.AreEqual(5, col.Count);
            Assert.AreEqual(5, col.CreatedBusinessObjects.Count);
            Assert.AreEqual(5, table.Rows.Count);
        }
        public void TestAddRowCreatesBusinessObjectThroughCollection()
        {
            SetupTestData();
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> boCollection = new BusinessObjectCollection <MyBO>();
            MyBO bo = new MyBO();

            bo.SetPropertyValue("TestProp", "bo1prop1");
            bo.SetPropertyValue("TestProp2", "s1");
            bo.Save();
            boCollection.Add(bo);

            MyBO bo2 = new MyBO();

            bo2.SetPropertyValue("TestProp", "bo2prop1");
            bo2.SetPropertyValue("TestProp2", "s2");
            bo2.Save();
            boCollection.Add(bo2);

            _dataSetProvider = new EditableDataSetProvider(boCollection);
            BOMapper mapper = new BOMapper(boCollection.ClassDef.CreateNewBusinessObject());

            itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);


            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, boCollection.Count);
            Assert.AreEqual(0, boCollection.CreatedBusinessObjects.Count, "Should be no created items to start");

            //---------------Execute Test ----------------------
            itsTable.Rows.Add(new object[] { null, "bo3prop1", "bo3prop2" });

            //---------------Test Result -----------------------
            Assert.AreEqual
                (1, boCollection.CreatedBusinessObjects.Count,
                "Adding a row to the table should use the collection to create the object");
            //Assert.AreEqual(2, boCollection.Count, "Adding a row to the table should not add a bo to the main collection");
            Assert.AreEqual(3, boCollection.Count, "Adding a row to the table should add a bo to the main collection");
        }
Exemplo n.º 9
0
        public void TestInitGrid_UIDef_DateFormat_FormatsDateColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef    = MyBO.LoadClassDefWithDateTimeParameterFormat();
            IReadOnlyGridControl grid        = CreateReadOnlyGridControl();
            IGridInitialiser     initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef  uiDef     = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;

            AddControlToForm(grid);
            GlobalUIRegistry.DateDisplaySettings = new DateDisplaySettings();
            GlobalUIRegistry.DateDisplaySettings.GridDateFormat = "dd MMM yyyy";
            //--------------Assert PreConditions----------------
            const string formattedPropertyName = "TestDateTimeFormat";

            Assert.IsNotNull(uiGridDef[formattedPropertyName]);
            Assert.IsNotNull(uiGridDef["TestDateTimeNoFormat"]);
            Assert.IsNotNull(uiGridDef["TestDateTime"]);

            Assert.IsNull(uiGridDef["TestDateTimeNoFormat"].GetParameterValue("dateFormat"));
            Assert.IsNull(uiGridDef["TestDateTime"].GetParameterValue("dateFormat"));
            object       dateFormatObject    = uiGridDef[formattedPropertyName].GetParameterValue("dateFormat");
            string       dateFormatParameter = dateFormatObject.ToString();
            const string expectedFormat      = "dd.MMM.yyyy";

            Assert.AreEqual(expectedFormat, dateFormatParameter);

            MyBO     myBo            = new MyBO();
            DateTime currentDateTime = DateTime.Now;

            myBo.SetPropertyValue(formattedPropertyName, currentDateTime);
            BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>();

            col.Add(myBo);

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            grid.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[formattedPropertyName];

            //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false;
            Assert.AreSame(typeof(DateTime), dataGridViewCell.ValueType);
            Assert.AreEqual(currentDateTime.ToString(expectedFormat), dataGridViewCell.FormattedValue);

            //---------------Tear Down -------------------------
        }
        public void TestAddRowCreatesBusinessObjectThroughCollection()
        {
            SetupTestData();
            //---------------Set up test pack-------------------
            BusinessObjectCollection<MyBO> boCollection = new BusinessObjectCollection<MyBO>();
            MyBO bo = new MyBO();
            bo.SetPropertyValue("TestProp", "bo1prop1");
            bo.SetPropertyValue("TestProp2", "s1");
            bo.Save();
            boCollection.Add(bo);

            MyBO bo2 = new MyBO();
            bo2.SetPropertyValue("TestProp", "bo2prop1");
            bo2.SetPropertyValue("TestProp2", "s2");
            bo2.Save();
            boCollection.Add(bo2);

            _dataSetProvider = new EditableDataSetProvider(boCollection);
            BOMapper mapper = new BOMapper(boCollection.ClassDef.CreateNewBusinessObject());

            itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);


            //--------------Assert PreConditions----------------            
            Assert.AreEqual(2, boCollection.Count);
            Assert.AreEqual(0, boCollection.CreatedBusinessObjects.Count, "Should be no created items to start");

            //---------------Execute Test ----------------------
            itsTable.Rows.Add(new object[] {null, "bo3prop1", "bo3prop2"});

            //---------------Test Result -----------------------
            Assert.AreEqual
                (1, boCollection.CreatedBusinessObjects.Count,
                 "Adding a row to the table should use the collection to create the object");
            //Assert.AreEqual(2, boCollection.Count, "Adding a row to the table should not add a bo to the main collection");
            Assert.AreEqual(3, boCollection.Count, "Adding a row to the table should add a bo to the main collection");
        }
Exemplo n.º 11
0
        public void TestInitGrid_UIDef_CurrencyFormat_WhenVirtualProp_ShouldFormatColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef    = MyBO.LoadClassDefWithCurrencyParameterFormat();
            IReadOnlyGridControl grid        = CreateReadOnlyGridControl();
            IGridInitialiser     initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef  uiDef     = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;

            AddControlToForm(grid);

            //--------------Assert PreConditions----------------
            const string formattedPropertyName = "TestCurrencyFormat";

            Assert.IsNotNull(uiGridDef[formattedPropertyName]);
            Assert.IsNotNull(uiGridDef[formattedPropertyName].GetParameterValue("currencyFormat"));

            const string unformattedPropName = "TestCurrencyNoFormat";

            Assert.IsNotNull(uiGridDef[unformattedPropName]);
            Assert.IsNull(uiGridDef[unformattedPropName].GetParameterValue("currencyFormat"));

            object       currencyFormat          = uiGridDef[formattedPropertyName].GetParameterValue("currencyFormat");
            string       currencyFormatParameter = currencyFormat.ToString();
            const string expectedFormat          = "### ###.##";

            Assert.AreEqual(expectedFormat, currencyFormatParameter);

            MyBO         myBo          = new MyBO();
            const double currencyValue = 222222.55555d;

            myBo.SetPropertyValue(formattedPropertyName, currencyValue);
            BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>();

            col.Add(myBo);

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            grid.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[formattedPropertyName];

            //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false;
            Assert.AreSame(typeof(Double), dataGridViewCell.ValueType);
            Assert.AreEqual(currencyValue.ToString(expectedFormat), dataGridViewCell.FormattedValue);
        }
Exemplo n.º 12
0
        protected void SetupClassDefs(object propValue)
        {
            ClassDef.ClassDefs.Clear();
            IClassDef itsClassDef        = MyBO.LoadClassDefWithRelationship();
            IClassDef itsRelatedClassDef = MyRelatedBo.LoadClassDef();

            itsMyBo = (MyBO)itsClassDef.CreateNewBusinessObject();
            MyRelatedBo relatedBo       = (MyRelatedBo)itsRelatedClassDef.CreateNewBusinessObject();
            Guid        myRelatedBoGuid = relatedBo.ID.GetAsGuid();

            itsMyBo.SetPropertyValue("RelatedID", myRelatedBoGuid);
            relatedBo.SetPropertyValue("MyRelatedTestProp", propValue);
            itsMyBo.Save();
            relatedBo.Save();
        }
Exemplo n.º 13
0
        public void Test_GetPropertyValue_WithDot()
        {
            ClassDef.ClassDefs.Clear();
            _itsClassDef        = MyBO.LoadClassDefWithRelationship();
            _itsRelatedClassDef = MyRelatedBo.LoadClassDef();
            //MyBO bo1 = (MyBO)itsClassDef.CreateNewBusinessObject(connection);
            MyBO        bo1             = (MyBO)_itsClassDef.CreateNewBusinessObject();
            MyRelatedBo relatedBo       = (MyRelatedBo)_itsRelatedClassDef.CreateNewBusinessObject();
            Guid        myRelatedBoGuid = relatedBo.ID.GetAsGuid();

            bo1.SetPropertyValue("RelatedID", myRelatedBoGuid);
            relatedBo.SetPropertyValue("MyRelatedTestProp", "MyValue");
            BOMapper mapper = new BOMapper(bo1);

            Assert.AreEqual("MyValue", mapper.GetPropertyValueToDisplay("MyRelationship.MyRelatedTestProp"));
        }
Exemplo n.º 14
0
        public void TestPanelSetup()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();

            myBO.TestProp = START_VALUE_1;
            myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2);
            PanelBuilder factory = new PanelBuilder(GetControlFactory());

            //---------------Execute Test ----------------------
            IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);

            panelInfo.BusinessObject = myBO;
            //---------------Test Result -----------------------
            Assert.AreEqual(START_VALUE_1, panelInfo.FieldInfos[TEST_PROP_1].ControlMapper.Control.Text);
            Assert.AreEqual(START_VALUE_2, panelInfo.FieldInfos[TEST_PROP_2].ControlMapper.Control.Text);
        }
Exemplo n.º 15
0
        public void TestWinRowIsRefreshed()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IGridBase gridBase = GetGridBaseWith_4_Rows(out col);
            MyBO      bo       = col[0];

            //---------------Execute Test ----------------------
            const string propName = "TestProp";

            bo.SetPropertyValue(propName, "UpdatedValue");

            //---------------Test Result -----------------------
            gridBase.SelectedBusinessObject = bo;
            //System.Windows.Forms.DataGridViewRow row = (System.Windows.Forms.DataGridViewRow) gridBase.Rows[0];
            //System.Windows.Forms.DataGridViewCell cell = row.Cells[propName];
            System.Windows.Forms.DataGridViewCell cell = GetCell(0, propName, gridBase);
            Assert.AreEqual("UpdatedValue", cell.Value);
        }
        public void TestChangeControlValues_DoesNotChangeBusinessObjectValues()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();

            myBO.TestProp = START_VALUE_1;
            myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2);

            Habanero.Faces.Base.PanelBuilder factory = new Habanero.Faces.Base.PanelBuilder(GetControlFactory());
            IPanelInfo panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);

            panelInfo.BusinessObject = myBO;
            //---------------Execute Test ----------------------
            ChangeValuesInControls(panelInfo);
            //---------------Test Result -----------------------

            Assert.AreEqual(START_VALUE_1, myBO.GetPropertyValue(TEST_PROP_1));
            Assert.AreEqual(START_VALUE_2, myBO.GetPropertyValue(TEST_PROP_2));
        }
Exemplo n.º 17
0
        public void TestApplyChangesToBusinessObject()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            MyBO myBO = new MyBO();

            myBO.TestProp = START_VALUE_1;
            myBO.SetPropertyValue(TEST_PROP_2, START_VALUE_2);

            PanelBuilder factory   = new PanelBuilder(GetControlFactory());
            IPanelInfo   panelInfo = factory.BuildPanelForForm(myBO.ClassDef.UIDefCol["default"].UIForm);

            panelInfo.BusinessObject = myBO;
            ChangeValuesInControls(panelInfo);

            //---------------Execute Test ----------------------

            panelInfo.ApplyChangesToBusinessObject();
            //---------------Test Result -----------------------

            Assert.AreEqual(CHANGED_VALUE_1, myBO.GetPropertyValue(TEST_PROP_1));
            Assert.AreEqual(CHANGED_VALUE_2, myBO.GetPropertyValue(TEST_PROP_2));
        }
        public void TestLoadingRelatedObjectWithSingleTableInheritance()
        {
            //---------------Set up test pack-------------------
            DatabaseConnection.CurrentConnection.ExecuteRawSql(
                "delete from filledcircle_table; delete from circle_table; delete from shape_table");
            //MyBO has a relationship to Shape. Shape potentially has a circle for single table inheritance.
            MyBO.LoadClassDefWithShape_SingleTableInheritance_Relationship();

            MyBO bo = new MyBO();
            CircleNoPrimaryKey circle = new CircleNoPrimaryKey();
            circle.Radius = 5;
            circle.ShapeName = "MyShape";
            circle.Save();
            bo.SetPropertyValue("ShapeID", circle.ShapeID);
            bo.Save();

            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Execute Test ----------------------
            bo = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject<MyBO>(bo.ID);
            Shape shape = bo.Shape;

            //---------------Test Result -----------------------
            Assert.AreSame(typeof (CircleNoPrimaryKey), shape.GetType());
            Assert.IsFalse(shape.Status.IsNew);
            Assert.IsFalse(shape.Status.IsDeleted);
            Assert.IsFalse(shape.Status.IsEditing);
            Assert.IsFalse(shape.Status.IsDirty);
            Assert.IsTrue(shape.Status.IsValid());
        }
 public void TestAddRow_ThenAddBO_UpdatesTable()
 {
     BusinessObjectCollection<MyBO> col = null;
     IDataSetProvider dataSetProvider = GetDataSetProviderWithCollection(ref col);
     BOMapper mapper = new BOMapper(col.ClassDef.CreateNewBusinessObject());
     DataTable table = dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);
     MyBO boNew = new MyBO();
     boNew.SetPropertyValue("TestProp", "bo3prop1");
     boNew.SetPropertyValue("TestProp2", "s2");
     //---------------Assert Precondition----------------
     Assert.AreEqual(4, table.Rows.Count);
     Assert.AreEqual(4, col.Count);
     Assert.AreEqual(4, col.CreatedBusinessObjects.Count);
     //---------------Execute Test ----------------------
     table.Rows.Add(new object[] { null, "bo3prop1", "bo3prop2" });
     col.Add(boNew);
     //---------------Test Result -----------------------
     Assert.AreEqual(6, col.Count);
     Assert.AreEqual(6, col.CreatedBusinessObjects.Count);
     Assert.AreEqual(6, table.Rows.Count);
 }