public virtual void TestInitGrid_LoadsDataGridViewComboBoxColumn_WhenPropDefMissing()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef = MyBO.LoadClassDefWith_Grid_1ComboBoxColumn();
            IEditableGridControl grid     = GetControlFactory().CreateEditableGridControl();

            DisposeOnTearDown(grid);
            IGridInitialiser initialiser   = new GridBaseInitialiser(grid.Grid, GetControlFactory());
            IUIDef           uiDef         = classDef.UIDefCol["default"];
            IUIGrid          uiGridDef     = uiDef.UIGrid;
            IUIGridColumn    uiComboColDef = uiGridDef[0];

            uiComboColDef.GridControlTypeName = "DataGridViewComboBoxColumn";
            uiComboColDef.PropertyName        = "OtherProp";
            AddControlToForm(grid);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, grid.Grid.Columns.Count);
            IDataGridViewColumn column1 = grid.Grid.Columns[1];

            Assert.AreEqual("OtherProp", column1.Name);
            Assert.AreEqual(uiComboColDef.Heading, column1.HeaderText);
            Assert.IsInstanceOf(typeof(IDataGridViewComboBoxColumn), column1);
            AssertGridColumnTypeAfterCast(column1, GetComboBoxGridColumnType());
        }
        public virtual void TestInitGrid_LoadsDataGridViewDateTimeColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef = MyBO.LoadClassDefWithDateTimeParameterFormat();
            IEditableGridControl grid     = GetControlFactory().CreateEditableGridControl();

            DisposeOnTearDown(grid);
            IGridInitialiser initialiser = new GridBaseInitialiser(grid.Grid, GetControlFactory());
            IUIDef           uiDef       = classDef.UIDefCol["default"];
            IUIGrid          uiGridDef   = uiDef.UIGrid;
            IUIGridColumn    uiDTColDef  = uiGridDef[2];

            uiDTColDef.GridControlTypeName = "DataGridViewDateTimeColumn";
            AddControlToForm(grid);

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            //---------------Test Result -----------------------
            Assert.AreEqual(6, grid.Grid.Columns.Count);
            IDataGridViewColumn column3 = grid.Grid.Columns[3];

            Assert.AreEqual("TestDateTime", column3.Name);
            Assert.AreEqual(uiDTColDef.Heading, column3.HeaderText);
            Assert.IsInstanceOf(typeof(IDataGridViewColumn), column3);
            AssertGridColumnTypeAfterCast(column3, GetDateTimeGridColumnType());
        }
 public PropertyDescriptorPropDef(IUIGridColumn gridColumn)
     : base(gridColumn.PropertyName, null)
 {
     if (gridColumn == null) throw new ArgumentNullException("gridColumn");
     if(gridColumn.ClassDef == null) throw new HabaneroArgumentException("gridColumn.ClassDef");
     GridColumn = gridColumn;
 }
        public void TestInitGrid_UIDef_ZeroWidthColumn_HidesColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef    = MyBO.LoadClassDefWith_Grid_2Columns_1stHasZeroWidth();
            IReadOnlyGridControl grid        = CreateReadOnlyGridControl();
            IGridInitialiser     initialiser = new GridBaseInitialiser(grid.Grid, GetControlFactory());
            IUIDef  uiDef     = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;

            //---------------Assert Preconditions---------------
            Assert.AreEqual(2, uiGridDef.Count, "2 defined columns in the defaultDef");
            IUIGridColumn columnDef1 = uiGridDef[0];

            Assert.AreEqual("TestProp", columnDef1.PropertyName);
            Assert.AreEqual(0, columnDef1.Width);
            IUIGridColumn columnDef2 = uiGridDef[1];

            Assert.AreEqual("TestProp2", columnDef2.PropertyName);
            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);

            //---------------Test Result -----------------------
            IDataGridViewColumn dataColumn1 = grid.Grid.Columns[1];

            AssertThatDataColumnSetupCorrectly(classDef, columnDef1, dataColumn1);

            IDataGridViewColumn dataColumn2 = grid.Grid.Columns[2];

            AssertThatDataColumnSetupCorrectly(classDef, columnDef2, dataColumn2);
            //---------------Tear Down -------------------------
        }
        public void TestInitGrid_With_GridDef()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef    = LoadMyBoDefaultClassDef();
            IReadOnlyGridControl grid        = CreateReadOnlyGridControl();
            IGridInitialiser     initialiser = new GridBaseInitialiser(grid.Grid, GetControlFactory());
            IUIGrid uiGridDef = classDef.UIDefCol["default"].UIGrid;

            //---------------Assert Preconditions---------------
            Assert.AreEqual(2, uiGridDef.Count, "2 defined columns in the defaultDef");
            IUIGridColumn columnDef1 = uiGridDef[0];

            Assert.AreEqual("TestProp", columnDef1.PropertyName);
            IUIGridColumn columnDef2 = uiGridDef[1];

            Assert.AreEqual("TestProp2", columnDef2.PropertyName);
            //---------------Execute Test ----------------------

            initialiser.InitialiseGrid(classDef, uiGridDef, "test");
            //---------------Test Result -----------------------
            IDataGridViewColumn idColumn = grid.Grid.Columns[0];

            AssertVerifyIDFieldSetUpCorrectly(idColumn);

            IDataGridViewColumn dataColumn1 = grid.Grid.Columns[1];

            AssertThatDataColumnSetupCorrectly(classDef, columnDef1, dataColumn1);

            IDataGridViewColumn dataColumn2 = grid.Grid.Columns[2];

            AssertThatDataColumnSetupCorrectly(classDef, columnDef2, dataColumn2);

            //---------------Tear Down -------------------------
        }
示例#6
0
        public void Test_Construct_WithNoReflectiveProperty_ShouldRaiseError()
        {
            //This is a PropDescriptor that wraps a
            //UIGridColumn that wraps a PropDef and if the
            //PropDef is null this should therefore raise and error.
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn = GetGridColumnStub();

            //---------------Assert Precondition----------------
            Assert.IsNotNull(gridColumn.ClassDef);
            Assert.IsNull(ReflectionUtilities.GetPropertyInfo(gridColumn.ClassDef.ClassType, gridColumn.PropertyName));
            //---------------Execute Test ----------------------
            try
            {
                new PropertyDescriptorReflectiveProp(gridColumn);
                Assert.Fail("expected HabaneroArgumentException");
            }
            //---------------Test Result -----------------------
            catch (HabaneroArgumentException ex)
            {
                var expectedErrMessage
                    = string.Format("The GridColumn for reflective property '{0}' "
                                    + "is invalid since this reflective property does not exist on the class of type '{1}' "
                                    , gridColumn.PropertyName, gridColumn.ClassDef.ClassName);
                StringAssert.Contains(expectedErrMessage, ex.Message);
                Assert.AreEqual("gridColumn", ex.ParameterName);
            }
        }
示例#7
0
        public void Test_Construct_WhenPropDefsClassDef_NotSameAs_GridColumnsClassDef_ShouldRaiseError()
        {
            //This is a PropDescriptor that wraps a
            //UIGridColumn that wraps a PropDef if this
            // PropDef is a related PropDef e.g. on Order using Customer.CustomerName
            // the the PropDefs ClassDef and the GridColumns ClassDef will not be the same.
            // The PropertyDescriptorRelatedPropDef should be used instead.
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn = MockRepository.GenerateStub <IUIGridColumn>();

            gridColumn.PropertyName = RandomValueGen.GetRandomString();
            //---------------Assert Precondition----------------
            Assert.IsFalse(gridColumn.HasPropDef);
            //---------------Execute Test ----------------------
            try
            {
                new PropertyDescriptorPropDef(gridColumn);
                Assert.Fail("expected ArgumentNullException");
            }
            //---------------Test Result -----------------------
            catch (HabaneroArgumentException ex)
            {
                Assert.AreEqual("gridColumn.ClassDef", ex.ParameterName);
            }
        }
示例#8
0
        private IUIGridColumn GetGridColumnStub(IClassDef classDef)
        {
            IUIGridColumn gridColumn = MockRepository.GenerateStub <IUIGridColumn>();

            gridColumn.PropertyName = RandomValueGen.GetRandomString();
            gridColumn.Stub(column => column.ClassDef).Return(classDef);
            return(gridColumn);
        }
        public void TestCustomColumnType()
        {
            IUIGridColumn uiProp =
                loader.LoadUIProperty(@"<column heading=""testheading"" property=""testpropname"" type=""DataGridViewComboBoxColumn"" assembly=""System.Windows.Forms"" />");

            Assert.AreEqual("DataGridViewComboBoxColumn", uiProp.GridControlTypeName);
            Assert.AreEqual("System.Windows.Forms", uiProp.GridControlAssemblyName);
        }
        public void Test_LoadUIProperty_WithCustomUnknownColumnType()
        {
            IUIGridColumn uiProp =
                loader.LoadUIProperty(@"<column property=""testpropname"" type=""MyColumnType"" assembly=""MyAssembly"" />");

            Assert.AreEqual("MyColumnType", uiProp.GridControlTypeName);
            Assert.AreEqual("MyAssembly", uiProp.GridControlAssemblyName);
        }
示例#11
0
        public void TestAutomaticHeadingCreation_UsingCamelCase()
        {
            XmlUIGridColumnLoader loader = new XmlUIGridColumnLoader(new DtdLoader(), new DefClassFactory());
            IUIGridColumn         uiProp = loader.LoadUIProperty(@"<column property=""TestPropName"" />");

            Assert.AreEqual(null, uiProp.Heading);
            Assert.AreEqual("Test Prop Name", uiProp.GetHeading());
        }
        public void TestPropertyAttributes()
        {
            IUIGridColumn uiProp =
                loader.LoadUIProperty(
                    @"<column heading=""testlabel"" property=""testpropname"" ><parameter name=""TestAtt"" value=""TestValue"" /><parameter name=""TestAtt2"" value=""TestValue2"" /></column>");

            Assert.AreEqual("TestValue", uiProp.GetParameterValue("TestAtt"));
            Assert.AreEqual("TestValue2", uiProp.GetParameterValue("TestAtt2"));
        }
        private static IPropDef GetPropDef(IClassDef classDef, IUIGridColumn gridColumn)
        {
            /*            IPropDef propDef = null;
             *          if (classDef.PropDefColIncludingInheritance.Contains(gridColumn.PropertyName))
             *          {
             *              propDef = classDef.PropDefColIncludingInheritance[gridColumn.PropertyName];
             *          }*/

            return(classDef.GetPropDef(gridColumn.PropertyName, false));
        }
        public void TestSimpleUIProperty()
        {
            IUIGridColumn uiProp =
                loader.LoadUIProperty(
                    @"<column heading=""testheading"" property=""testpropname"" type=""DataGridViewCheckBoxColumn"" width=""40"" />");

            Assert.AreEqual("testheading", uiProp.Heading);
            Assert.AreEqual("testpropname", uiProp.PropertyName);
            Assert.AreEqual(40, uiProp.Width);
        }
 public PropertyDescriptorReflectiveProp(IUIGridColumn gridColumn)
     : base(gridColumn.PropertyName, null)
 {
     if (gridColumn == null) throw new ArgumentNullException("gridColumn");
     if(gridColumn.ClassDef == null) throw new HabaneroArgumentException("gridColumn.ClassDef");
     GridColumn = gridColumn;
     var propertyName = gridColumn.PropertyName.Trim('-');
     PropInfo = ReflectionUtilities.GetPropertyInfo(gridColumn.ClassDef.ClassType, propertyName);
     CheckPropInfo(gridColumn);
 }
 protected virtual void CheckPropInfo(IUIGridColumn gridColumn)
 {
     if(PropInfo.IsNull())
     {
         var errMessage 
             = string.Format("The GridColumn for reflective property '{0}' " 
                             + "is invalid since this reflective property does not exist on the class of type '{1}' "
                             , gridColumn.PropertyName, gridColumn.ClassDef.ClassName);
         throw new HabaneroArgumentException("gridColumn", errMessage);
     }
 }
 protected virtual void CheckPropInfo(IUIGridColumn gridColumn)
 {
     if (PropInfo.IsNull())
     {
         var errMessage
             = string.Format("The GridColumn for reflective property '{0}' "
                             + "is invalid since this reflective property does not exist on the class of type '{1}' "
                             , gridColumn.PropertyName, gridColumn.ClassDef.ClassName);
         throw new HabaneroArgumentException("gridColumn", errMessage);
     }
 }
示例#18
0
        public void Test_Construct_ShouldConstruct()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn = GetGridColumnStub();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            PropertyDescriptor propDescriptor = new PropertyDescriptorPropDef(gridColumn);

            //---------------Test Result -----------------------
            Assert.IsNotNull(propDescriptor);
        }
示例#19
0
        public void Test_Editable_WhenSetToFalse_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn = GetGridColumnSpy();

            //---------------Assert Precondition----------------
            Assert.IsTrue(gridColumn.Editable);
            //---------------Execute Test ----------------------
            gridColumn.Editable = false;
            //---------------Test Result -----------------------
            Assert.IsFalse(gridColumn.Editable);
        }
示例#20
0
        public void Test_HashCodeEquals()
        {
            //---------------Set up test pack-------------------
            UIGridColumn  gridColumn       = new UIGridColumn("pp", "pp", "", "", false, 0, PropAlignment.centre, null);
            IUIGridColumn clonedGridColumn = gridColumn.Clone();

            //---------------Assert preconditions----------------
            Assert.IsTrue(gridColumn.Equals(clonedGridColumn));
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.AreEqual(gridColumn.GetHashCode(), clonedGridColumn.GetHashCode());
        }
示例#21
0
 public PropertyDescriptorPropDef(IUIGridColumn gridColumn)
     : base(gridColumn.PropertyName, null)
 {
     if (gridColumn == null)
     {
         throw new ArgumentNullException("gridColumn");
     }
     if (gridColumn.ClassDef == null)
     {
         throw new HabaneroArgumentException("gridColumn.ClassDef");
     }
     GridColumn = gridColumn;
 }
        protected static void SetupCurrencyWithParameters(Type propertyType, IUIGridColumn gridColDef, IDataGridViewColumn column)
        {
            if (propertyType != typeof(Double) && propertyType != typeof(Decimal))
            {
                return;
            }
            string currencyFormat = gridColDef.GetParameterValue("currencyFormat") as string;

            if (currencyFormat != null)
            {
                column.DefaultCellStyle.Format = currencyFormat;
            }
        }
示例#23
0
        public void TestCloneGridColumn()
        {
            //---------------Set up test pack-------------------
            UIGridColumn gridColumn = new UIGridColumn("pp", "pp", "", "", false, 0, PropAlignment.centre, null);

            //---------------Execute Test ----------------------
            IUIGridColumn clonedGridColumn = gridColumn.Clone();

            //---------------Test Result -----------------------
            Assert.IsTrue(gridColumn.Equals(clonedGridColumn));
            Assert.IsTrue(gridColumn == (UIGridColumn)clonedGridColumn);
            Assert.IsFalse(gridColumn != (UIGridColumn)clonedGridColumn);
        }
示例#24
0
        public void Test_PropDef_WhenHas_ShouldReturnPropDef()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn = GetGridColumn();

            //---------------Assert Precondition----------------
            Assert.IsTrue(((UIGridColumn)gridColumn).HasPropDef);
            //---------------Execute Test ----------------------
            IPropDef propDef = gridColumn.PropDef;

            //---------------Test Result -----------------------
            Assert.IsNotNull(propDef);
        }
        //This code could be moved into a factory for creation at a later date.
        //Also with changes made to Habanero could now have one property descriptor using BOProperty Mapper or
        //ReflectionPropertyMapper as appropriate.
        protected static PropertyDescriptor GetPropertyDescriptor(IUIGridColumn column)
        {
            PropertyDescriptor propertyDescriptorPropDef;

            if (column.HasPropDef)
            {
                propertyDescriptorPropDef = new PropertyDescriptorPropDef(column);
            }
            else
            {
                propertyDescriptorPropDef = new PropertyDescriptorReflectiveProp(column);
            }
            return(propertyDescriptorPropDef);
        }
示例#26
0
        public void Test_PropDef_WhenNotHas_ShouldReturnNull()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn = GetGridColumn();

            gridColumn.PropertyName = "SomeNonExistentName";
            //---------------Assert Precondition----------------
            Assert.IsFalse(gridColumn.HasPropDef);
            //---------------Execute Test ----------------------
            IPropDef propDef = gridColumn.PropDef;

            //---------------Test Result -----------------------
            Assert.IsNull(propDef);
        }
        public void TestNoDefaultColumnType()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn uiProp =
                loader.LoadUIProperty(
                    @"<column heading=""testheading"" property=""testpropname""   />");

            //---------------Verify test pack-------------------

            //---------------Execute Test ----------------------
            //---------------Verify Result -----------------------
            Assert.IsTrue(string.IsNullOrEmpty(uiProp.GridControlTypeName));
            Assert.IsTrue(string.IsNullOrEmpty(uiProp.GridControlAssemblyName));
            //---------------Tear Down -------------------------
        }
示例#28
0
        public void Test_LookupList_WhenNotSet_ShouldBeNull()
        {
            //---------------Set up test pack-------------------
            IClassDef                 classDef       = MockRepository.GenerateStub <IClassDef>();
            IUIGridColumn             gridColumn     = GetGridColumnStub(classDef);
            PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn);

            //---------------Assert Precondition----------------
            Assert.IsNull(classDef.GetLookupList(gridColumn.PropertyName));
            //---------------Execute Test ----------------------
            ILookupList lookupList = propDescriptor.LookupList;

            //---------------Test Result -----------------------
            Assert.IsNull(lookupList);
        }
示例#29
0
        public void Test_Alignment_ShouldReturnAlignmentFromColumn()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn        = GetGridColumnStub();
            var           expectedAlignment = RandomValueGen.GetRandomEnum <PropAlignment>(); gridColumn.Alignment = expectedAlignment;

            PropertyDescriptorReflectiveProp propDescriptor = new PropertyDescriptorReflectivePropSpy(gridColumn);

            //---------------Assert Precondition----------------
            Assert.AreEqual(expectedAlignment, gridColumn.Alignment);
            //---------------Execute Test ----------------------
            var alignment = propDescriptor.Alignment;

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedAlignment, alignment);
        }
        public void TestInitGrid_GlobalDateFormat_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);
            const string dateTimeNoFormatPropertyName = "TestDateTimeNoFormat";

            const string expectedFormat = "dd.MMM.yyyy";

            GlobalUIRegistry.DateDisplaySettings = new DateDisplaySettings();
            GlobalUIRegistry.DateDisplaySettings.GridDateFormat = expectedFormat;
            //--------------Assert PreConditions----------------
            IUIGridColumn dateTimeNoFormatGridColumn = uiGridDef[dateTimeNoFormatPropertyName];

            Assert.IsNotNull(dateTimeNoFormatGridColumn);
            Assert.IsNull(dateTimeNoFormatGridColumn.GetParameterValue("dateFormat"));
            Assert.IsNotNull(GlobalUIRegistry.DateDisplaySettings);
            Assert.AreEqual(expectedFormat, GlobalUIRegistry.DateDisplaySettings.GridDateFormat);

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

            myBo.SetPropertyValue(dateTimeNoFormatPropertyName, 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[dateTimeNoFormatPropertyName];

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

            //---------------Tear Down -------------------------
        }
示例#31
0
        public void Test_DisplayName_ShouldBeGridColumnDisplayName()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn          = GetGridColumnStub();
            var           expectedDispalyName = RandomValueGen.GetRandomString();

            gridColumn.Stub(column => column.GetHeading()).Return(expectedDispalyName);
            PropertyDescriptor propDescriptor = new PropertyDescriptorPropDef(gridColumn);

            //---------------Assert Precondition----------------
            Assert.AreEqual(expectedDispalyName, gridColumn.GetHeading());
            //---------------Execute Test ----------------------
            var actualPropDescriptorDisplayName = propDescriptor.DisplayName;

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedDispalyName, actualPropDescriptorDisplayName);
        }
        public PropertyDescriptorReflectiveProp(IUIGridColumn gridColumn)
            : base(gridColumn.PropertyName, null)
        {
            if (gridColumn == null)
            {
                throw new ArgumentNullException("gridColumn");
            }
            if (gridColumn.ClassDef == null)
            {
                throw new HabaneroArgumentException("gridColumn.ClassDef");
            }
            GridColumn = gridColumn;
            var propertyName = gridColumn.PropertyName.Trim('-');

            PropInfo = ReflectionUtilities.GetPropertyInfo(gridColumn.ClassDef.ClassType, propertyName);
            CheckPropInfo(gridColumn);
        }
示例#33
0
        public void Test_Name_ShouldBeGridColumnPropertyName()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn   = GetGridColumnStub();
            string        expectedName = RandomValueGen.GetRandomString();

            gridColumn.PropertyName = expectedName;
            PropertyDescriptor propDescriptor = new PropertyDescriptorPropDef(gridColumn);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var actualPropDescriptorName = propDescriptor.Name;

            //propDescriptor.DisplayName
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedName, actualPropDescriptorName);
        }
 protected override void CheckPropInfo(IUIGridColumn gridColumn)
 {
 }
 private static void SetupDateTimeWithParameters(Type propertyType, IUIGridColumn gridColDef, IDataGridViewColumn col)
 {
     if (propertyType != typeof(DateTime)) return;
     string dateFormat = gridColDef.GetParameterValue("dateFormat") as string;
     if (string.IsNullOrEmpty(dateFormat) && GlobalUIRegistry.DateDisplaySettings != null)
     {
         dateFormat = GlobalUIRegistry.DateDisplaySettings.GridDateFormat;
     }
     if (dateFormat != null)
     {
         col.DefaultCellStyle.Format = dateFormat;
     }
 }
 private static IPropDef GetPropDef(IClassDef classDef, IUIGridColumn gridColumn)
 {
     IPropDef propDef = classDef.GetPropDef(gridColumn.PropertyName, false);
     return propDef;
 }
 private static void SetupColumnWithDefParameters(IDataGridViewColumn col, IUIGridColumn gridColDef, Type propertyType)
 {
     SetupDateTimeWithParameters(propertyType, gridColDef, col);
     SetupCurrencyWithParameters(propertyType, gridColDef ,col);
 }
 protected static void SetupCurrencyWithParameters(Type propertyType, IUIGridColumn gridColDef, IDataGridViewColumn column)
 {
     if (propertyType != typeof(Double) && propertyType != typeof(Decimal)) return;
     string currencyFormat = gridColDef.GetParameterValue("currencyFormat") as string;
     if (currencyFormat != null)
     {
         column.DefaultCellStyle.Format = currencyFormat;
     }
 }
        private IDataGridViewColumn CreateCustomColumn(IUIGridColumn columnDef)
        {
            IDataGridViewColumn newColumn;
            var uiGridColumn = columnDef as UIGridColumn;
            if (uiGridColumn != null && uiGridColumn.GridControlType != null)
            {
                newColumn = _controlFactory.CreateDataGridViewColumn(uiGridColumn.GridControlType);
            }
            else
            {
                newColumn = _controlFactory.CreateDataGridViewColumn
                    (columnDef.GridControlTypeName, columnDef.GridControlAssemblyName);
            }

            GridBase.Columns.Add(newColumn);
            return newColumn;
        }
示例#40
0
        private void AddColumn(IUIGridColumn uiProperty, IClassDef classDef)
        {
            DataColumn column = _table.Columns.Add();
            if (_table.Columns.Contains(uiProperty.PropertyName))
            {
                throw new DuplicateNameException
                    (String.Format
                         ("In a grid definition, a duplicate column with "
                          + "the name '{0}' has been detected. Only one column " + "per property can be specified.",
                          uiProperty.PropertyName));
            }
            Type columnPropertyType = GetPropertyType(classDef, uiProperty.PropertyName);

            column.DataType = columnPropertyType;
            column.ColumnName = uiProperty.PropertyName;
            column.Caption = uiProperty.ClassDef == null 

                        ? uiProperty.GetHeading(classDef) 
                        : uiProperty.GetHeading();
            //TODO brett 06 Jul 2010: These extended properties are never used by faces any more
            // and can be removed from this column.
            column.ExtendedProperties.Add("LookupList", uiProperty.LookupList);
            column.ExtendedProperties.Add("Width", uiProperty.Width);
            column.ExtendedProperties.Add("Alignment", uiProperty.Alignment);
        }
            //        IUIGridColumn gridColumn = MockRepository.GenerateStub<IUIGridColumn>();
            //string expectedFormat = "fdafasdfsda";
            //gridColumn.Stub(column => column.GetParameterValue("currencyFormat")).Return(expectedFormat);
            //IDataGridViewColumn gridViewColumn = MockRepository.GenerateStub<IDataGridViewColumn>();

            //gridViewColumn.DefaultCellStyle = MockRepository.GenerateStub<IDataGridViewCellStyle>();
            ////--------------Assert PreConditions----------------            
            //Assert.AreNotEqual(expectedFormat, gridViewColumn.DefaultCellStyle.Format); 

            ////---------------Execute Test ----------------------
            //gridInitialiser.CallSetupCurrencyWithParameters(typeof (Decimal), gridColumn, gridViewColumn);
        internal void CallSetupCurrencyWithParameters(Type propertyType, IUIGridColumn gridColumn, IDataGridViewColumn gridViewColumn ) 
        {
           SetupCurrencyWithParameters(propertyType, gridColumn, gridViewColumn);
        }
        private static void AssertThatDataColumnSetupCorrectly
            (IClassDef classDef, IUIGridColumn columnDef1, IDataGridViewColumn dataColumn1)
        {
            Assert.AreEqual(columnDef1.PropertyName, dataColumn1.DataPropertyName); //Test Prop
            Assert.AreEqual(columnDef1.PropertyName, dataColumn1.Name);
            Assert.AreEqual(columnDef1.GetHeading(), dataColumn1.HeaderText);
            Assert.AreEqual(columnDef1.Width != 0, dataColumn1.Visible);
//            Assert.IsTrue(dataColumn1.ReadOnly); TODO: put this test into the readonlygridinitialiser
            int expectedWidth = columnDef1.Width;
            if (expectedWidth == 0) expectedWidth = 5;
            Assert.AreEqual(expectedWidth, dataColumn1.Width);
            PropDef propDef = (PropDef) GetPropDef(classDef, columnDef1);
            Assert.AreEqual(propDef.PropertyType, dataColumn1.ValueType);
        }
 private static void AssertGridColumnTypeIsTextBox(IUIGridColumn gridColumn)
 {
     Assert.AreEqual("System.Windows.Forms", gridColumn.GridControlAssemblyName);
     Assert.AreEqual("DataGridViewTextBoxColumn", gridColumn.GridControlTypeName);
 }
 internal PropertyDescriptorReflectivePropSpy(IUIGridColumn gridColumn)
     : base(gridColumn)
 {
 }
 private static void AssertGridColumnTypeIsDateTime(IUIGridColumn gridColumn)
 {
     Assert.AreEqual("Habanero.Faces.Win", gridColumn.GridControlAssemblyName);
     Assert.AreEqual("DataGridViewDateTimeColumnWin", gridColumn.GridControlTypeName);
 }
        private static IPropDef GetPropDef(IClassDef classDef, IUIGridColumn gridColumn)
        {
            /*            IPropDef propDef = null;
                        if (classDef.PropDefColIncludingInheritance.Contains(gridColumn.PropertyName))
                        {
                            propDef = classDef.PropDefColIncludingInheritance[gridColumn.PropertyName];
                        }*/

            return classDef.GetPropDef(gridColumn.PropertyName, false);
        }
 internal PropertyDescriptorReflectivePropSpy(IUIGridColumn gridColumn, PropertyInfo propInfo)
     : base(gridColumn)
 {
     PropInfo = propInfo;
 }