示例#1
0
        public void TestProtectedSets()
        {
            UIGridColumnSpy column = new UIGridColumnSpy();

            Assert.AreEqual("heading", column.Heading);
            column.SetHeading("newheading");
            Assert.AreEqual("newheading", column.Heading);
            column.SetPropertyName(null);
            Assert.IsNull(column.PropertyName);
            column.SetPropertyName("prop");
            Assert.AreEqual("prop", column.PropertyName);

            Assert.IsNull(column.GridControlType);
            column.SetGridControlType(typeof(DataGridViewTextBoxColumn));
            Assert.AreEqual(typeof(DataGridViewTextBoxColumn), column.GridControlType);

            Assert.IsTrue(column.Editable);
            column.SetEditable(false);
            Assert.IsFalse(column.Editable);

            Assert.AreEqual(100, column.Width);
            column.SetWidth(200);
            Assert.AreEqual(200, column.Width);

            Assert.AreEqual(PropAlignment.left, column.Alignment);
            column.SetAlignment(PropAlignment.right);
            Assert.AreEqual(PropAlignment.right, column.Alignment);
        }
示例#2
0
        private static UIGridColumn GetGridColumn(IClassDef classDef, ILookupList lookupList)
        {
            UIGridColumnSpy gridColumn = new UIGridColumnSpy();

            classDef.GetLookupList(gridColumn.PropertyName);
            classDef.Stub(def => def.GetLookupList(gridColumn.PropertyName)).Return(lookupList);

            gridColumn.SetClassDef(classDef);
            return(gridColumn);
        }
示例#3
0
 public void Test_SetUIGrid_ShouldSetUIGrid()
 {
     //---------------Set up test pack-------------------
     var expectedGridDef = MockRepository.GenerateStub<IUIGrid>();
     IUIGridColumn uiGridColumn = new UIGridColumnSpy();
     //---------------Assert Precondition----------------
     Assert.IsNull(uiGridColumn.ClassDef);
     //---------------Execute Test ----------------------
     uiGridColumn.UIGrid = expectedGridDef;
     var actualGridDef = uiGridColumn.UIGrid;
     //---------------Test Result -----------------------
     Assert.AreSame(expectedGridDef, actualGridDef);
 }
示例#4
0
        public void Test_HasPropDef_WhenNotHas_ShouldRetFalse()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn gridColumn = new UIGridColumnSpy();

            //---------------Assert Precondition----------------
            Assert.IsNull(gridColumn.PropDef);
            //---------------Execute Test ----------------------
            bool hasPropDef = gridColumn.HasPropDef;

            //---------------Test Result -----------------------
            Assert.IsFalse(hasPropDef);
        }
示例#5
0
        private IUIGridColumn GetGridColumnSpy()
        {
            ClassDef        classDef     = CreateTestClassDef("");
            const string    propertyName = "TestProperty";
            UIGridColumnSpy gridColumn   = new UIGridColumnSpy(propertyName)
            {
                Editable = true
            };

            gridColumn.SetClassDef(classDef);
            gridColumn.SetPropDef(classDef.PropDefcol[propertyName]);
            return(gridColumn);
        }
示例#6
0
        public void Test_LookupList_WhenNullClassDef_ShouldReturnNullLookupList()
        {
            //---------------Set up test pack-------------------
            UIGridColumn gridColumn = new UIGridColumnSpy();

            //---------------Assert Precondition----------------
            Assert.IsNull(gridColumn.ClassDef);
            //---------------Execute Test ----------------------
            ILookupList actualLList = gridColumn.LookupList;

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <NullLookupList>(actualLList);
        }
示例#7
0
        public void Test_HasPropDef_WhenHas_ShouldRetTrue()
        {
            //---------------Set up test pack-------------------
            var gridColumn = new UIGridColumnSpy();

            gridColumn.SetPropDef(MockRepository.GenerateMock <IPropDef>());
            //---------------Assert Precondition----------------
            Assert.IsNotNull(gridColumn.PropDef);
            //---------------Execute Test ----------------------
            bool hasPropDef = gridColumn.HasPropDef;

            //---------------Test Result -----------------------
            Assert.IsTrue(hasPropDef);
        }
示例#8
0
        public void Test_SetPropName_SetsProtectedPropDefToNull()
        {
            //---------------Set up test pack-------------------
            var gridColumn = new UIGridColumnSpy();
            var propDef    = MockRepository.GenerateStub <IPropDef>();

            gridColumn.SetPropDef(propDef);
            //---------------Assert Precondition----------------
            Assert.AreSame(propDef, gridColumn.PropDef);
            //---------------Execute Test ----------------------
            gridColumn.PropertyName = RandomValueGen.GetRandomString();
            //---------------Test Result -----------------------
            Assert.IsNull(gridColumn.PropDef);
        }
示例#9
0
        public void Test_ClassDef_WhenUIDefNull_ShouldReturnNull()
        {
            //---------------Set up test pack-------------------
            IUIGridColumn uiGridColumn = new UIGridColumnSpy();

            //---------------Assert Precondition----------------
            Assert.IsNull(uiGridColumn.ClassDef);
            Assert.IsNull(uiGridColumn.UIGrid);
            //---------------Execute Test ----------------------
            var actualClassDef = uiGridColumn.ClassDef;

            //---------------Test Result -----------------------
            Assert.IsNull(actualClassDef);
        }
示例#10
0
        public void Test_GetPropertyType_WhenHasPropDef_ButNotSet_ShouldReturnPropDefPropType()
        {
            //---------------Set up test pack-------------------
            var gridColumn = new UIGridColumnSpy();
            var intPropDef = GetIntPropDef();

            gridColumn.SetPropDef(intPropDef);
            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(int), intPropDef.PropertyType);
            //---------------Execute Test ----------------------
            var propertyType = gridColumn.GetPropertyType();

            //---------------Test Result -----------------------
            Assert.AreSame(typeof(int), propertyType);
        }
示例#11
0
        public void Test_SetUIGrid_ShouldSetUIGrid()
        {
            //---------------Set up test pack-------------------
            var           expectedGridDef = MockRepository.GenerateStub <IUIGrid>();
            IUIGridColumn uiGridColumn    = new UIGridColumnSpy();

            //---------------Assert Precondition----------------
            Assert.IsNull(uiGridColumn.ClassDef);
            //---------------Execute Test ----------------------
            uiGridColumn.UIGrid = expectedGridDef;
            var actualGridDef = uiGridColumn.UIGrid;

            //---------------Test Result -----------------------
            Assert.AreSame(expectedGridDef, actualGridDef);
        }
示例#12
0
        public void Test_GetPropType_WhenSetPropDefViaSpy_ShouldReturnSetPropDefsType()
        {
            //This is actually testing an optimisation so that we do not
            // continually have to go refetch the PropDef for the Column
            //---------------Set up test pack-------------------
            var      gridColumn = new UIGridColumnSpy();
            IPropDef propDef    = GetIntPropDef();

            gridColumn.SetPropDef(propDef);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var propertyType = gridColumn.GetPropertyType();

            //---------------Test Result -----------------------
            Assert.AreSame(propDef.PropertyType, propertyType);
        }
示例#13
0
        public void Test_GetPropertyType_FromInterface_WhenPropDefLookupList_ShouldReturnObjectType()
        {
            //---------------Set up test pack-------------------
            var gridColumn = new UIGridColumnSpy();
            var propDef    = MockRepository.GenerateStub <IPropDef>();

            propDef.PropertyType = typeof(bool);
            propDef.Stub(def => def.HasLookupList()).Return(true);
            gridColumn.SetPropDef(propDef);
            //---------------Assert Precondition----------------
            Assert.IsTrue(propDef.HasLookupList());
            //---------------Execute Test ----------------------
            var propertyType = ((IUIGridColumn)gridColumn).GetPropertyType();

            //---------------Test Result -----------------------
            Assert.AreSame(typeof(object), propertyType);
        }
示例#14
0
        public void Test_GetPropertyType_WhenReflectiveProp_ReturnReflectivePropType()
        {
            //---------------Set up test pack-------------------
            var       gridColumn   = new UIGridColumnSpy();
            IClassDef classDef     = MockRepository.GenerateStub <IClassDef>();
            string    propertyName = gridColumn.PropertyName;

            classDef.Stub(def => def.GetPropertyType(propertyName)).Return(typeof(bool));
            gridColumn.SetClassDef(classDef);
            //---------------Assert Precondition----------------
            Assert.AreSame(typeof(bool), classDef.GetPropertyType(gridColumn.PropertyName));
            //---------------Execute Test ----------------------
            var propertyType = gridColumn.GetPropertyType();

            //---------------Test Result -----------------------
            Assert.AreSame(typeof(bool), propertyType);
        }
示例#15
0
        public void Test_ClassDef_ShouldReturnUIGridsClassDef()
        {
            //---------------Set up test pack-------------------
            var       expectedGridDef  = MockRepository.GenerateStub <IUIGrid>();
            IClassDef expectedClassDef = MockRepository.GenerateStub <IClassDef>();

            expectedGridDef.Stub(grid => grid.ClassDef).Return(expectedClassDef);
            IUIGridColumn uiGridColumn = new UIGridColumnSpy();

            //---------------Assert Precondition----------------
            Assert.IsNull(uiGridColumn.ClassDef);
            Assert.IsNotNull(expectedGridDef.ClassDef);
            //---------------Execute Test ----------------------
            uiGridColumn.UIGrid = expectedGridDef;
            var actualClassDef = uiGridColumn.ClassDef;

            //---------------Test Result -----------------------
            Assert.AreSame(expectedClassDef, actualClassDef);
        }
示例#16
0
        public void Test_Editable_WhenSetToTrue_WhenHasPropDefReadWrite_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            var gridColumn = new UIGridColumnSpy {
                Editable = true
            };
            var propDef = MockRepository.GenerateStub <IPropDef>();

            propDef.ReadWriteRule = PropReadWriteRule.ReadWrite;
            //---------------Assert Precondition----------------
            Assert.IsTrue(gridColumn.Editable);
            Assert.IsNull(gridColumn.PropDef);
            Assert.AreEqual(PropReadWriteRule.ReadWrite, propDef.ReadWriteRule);
            //---------------Execute Test ----------------------
            gridColumn.SetPropDef(propDef);
            var editable = gridColumn.Editable;

            //---------------Test Result -----------------------
            Assert.IsTrue(editable, "Both PropDef and GridColumn defined as editable so should be editable.");
        }
示例#17
0
        public void Test_Editable_WhenSetToFalse_WhenHasPropDefReadWrite_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            var gridColumn = new UIGridColumnSpy {
                Editable = false
            };
            var propDef = MockRepository.GenerateStub <IPropDef>();

            propDef.ReadWriteRule = PropReadWriteRule.ReadWrite;
            //---------------Assert Precondition----------------
            Assert.IsFalse(gridColumn.Editable);
            Assert.IsNull(gridColumn.PropDef);
            Assert.AreEqual(PropReadWriteRule.ReadWrite, propDef.ReadWriteRule);
            //---------------Execute Test ----------------------
            gridColumn.SetPropDef(propDef);
            var editable = gridColumn.Editable;

            //---------------Test Result -----------------------
            Assert.IsFalse(editable, "The GridColumn Editable False should override the PropDef ReadWrite.");
        }
示例#18
0
        private static UIGridColumn GetGridColumn(IClassDef classDef, ILookupList lookupList)
        {
            UIGridColumnSpy gridColumn = new UIGridColumnSpy();
            classDef.GetLookupList(gridColumn.PropertyName);
            classDef.Stub(def => def.GetLookupList(gridColumn.PropertyName)).Return(lookupList);

            gridColumn.SetClassDef(classDef);
            return gridColumn;
        }
示例#19
0
 public void Test_Editable_WhenSetToFalse_WhenHasPropDefReadWrite_ShouldReturnFalse()
 {
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy { Editable = false };
     var propDef = MockRepository.GenerateStub<IPropDef>();
     propDef.ReadWriteRule = PropReadWriteRule.ReadWrite;
     //---------------Assert Precondition----------------
     Assert.IsFalse(gridColumn.Editable);
     Assert.IsNull(gridColumn.PropDef);
     Assert.AreEqual(PropReadWriteRule.ReadWrite, propDef.ReadWriteRule);
     //---------------Execute Test ----------------------
     gridColumn.SetPropDef(propDef);
     var editable = gridColumn.Editable;
     //---------------Test Result -----------------------
     Assert.IsFalse(editable, "The GridColumn Editable False should override the PropDef ReadWrite.");
 }
示例#20
0
 public void Test_Editable_WhenSetToTrue_WhenHasPropDefReadWrite_ShouldReturnTrue()
 {
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy { Editable = true };
     var propDef = MockRepository.GenerateStub<IPropDef>();
     propDef.ReadWriteRule = PropReadWriteRule.ReadWrite;
     //---------------Assert Precondition----------------
     Assert.IsTrue(gridColumn.Editable);
     Assert.IsNull(gridColumn.PropDef);
     Assert.AreEqual(PropReadWriteRule.ReadWrite, propDef.ReadWriteRule);
     //---------------Execute Test ----------------------
     gridColumn.SetPropDef(propDef);
     var editable = gridColumn.Editable;
     //---------------Test Result -----------------------
     Assert.IsTrue(editable, "Both PropDef and GridColumn defined as editable so should be editable.");
 }
示例#21
0
 private IUIGridColumn GetGridColumnSpy()
 {
     ClassDef classDef = CreateTestClassDef("");
     const string propertyName = "TestProperty";
     UIGridColumnSpy gridColumn = new UIGridColumnSpy(propertyName) { Editable = true };
     gridColumn.SetClassDef(classDef);
     gridColumn.SetPropDef(classDef.PropDefcol[propertyName]);
     return gridColumn;
 }
示例#22
0
 public void Test_HasPropDef_WhenNotHas_ShouldRetFalse()
 {
     //---------------Set up test pack-------------------
     IUIGridColumn gridColumn = new UIGridColumnSpy();
     //---------------Assert Precondition----------------
     Assert.IsNull(gridColumn.PropDef);
     //---------------Execute Test ----------------------
     bool hasPropDef = gridColumn.HasPropDef;
     //---------------Test Result -----------------------
     Assert.IsFalse(hasPropDef);
 }
示例#23
0
 public void Test_HasPropDef_WhenHas_ShouldRetTrue()
 {
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy();
     gridColumn.SetPropDef(MockRepository.GenerateMock<IPropDef>());
     //---------------Assert Precondition----------------
     Assert.IsNotNull(gridColumn.PropDef);
     //---------------Execute Test ----------------------
     bool hasPropDef = gridColumn.HasPropDef;
     //---------------Test Result -----------------------
     Assert.IsTrue(hasPropDef);
 }
示例#24
0
 public void Test_GetPropertyType_FromInterface_WhenPropDefLookupList_ShouldReturnObjectType()
 {
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy();
     var propDef = MockRepository.GenerateStub<IPropDef>();
     propDef.PropertyType = typeof(bool);
     propDef.Stub(def => def.HasLookupList()).Return(true);
     gridColumn.SetPropDef(propDef);
     //---------------Assert Precondition----------------
     Assert.IsTrue(propDef.HasLookupList());
     //---------------Execute Test ----------------------
     var propertyType = ((IUIGridColumn)gridColumn).GetPropertyType();
     //---------------Test Result -----------------------
     Assert.AreSame(typeof(object), propertyType);
 }
示例#25
0
 public void Test_SetPropName_SetsProtectedPropDefToNull()
 {
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy();
     var propDef = MockRepository.GenerateStub<IPropDef>();
     gridColumn.SetPropDef(propDef);
     //---------------Assert Precondition----------------
     Assert.AreSame(propDef, gridColumn.PropDef);
     //---------------Execute Test ----------------------
     gridColumn.PropertyName = RandomValueGen.GetRandomString();
     //---------------Test Result -----------------------
     Assert.IsNull(gridColumn.PropDef);
 }
示例#26
0
 public void Test_GetPropertyType_WhenReflectiveProp_ReturnReflectivePropType()
 {
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy();
     IClassDef classDef = MockRepository.GenerateStub<IClassDef>();
     string propertyName = gridColumn.PropertyName;
     classDef.Stub(def => def.GetPropertyType(propertyName)).Return(typeof(bool));
     gridColumn.SetClassDef(classDef);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(bool), classDef.GetPropertyType(gridColumn.PropertyName));
     //---------------Execute Test ----------------------
     var propertyType = gridColumn.GetPropertyType();
     //---------------Test Result -----------------------
     Assert.AreSame(typeof(bool), propertyType);
 }
示例#27
0
 public void Test_GetPropertyType_WhenHasPropDef_ButNotSet_ShouldReturnPropDefPropType()
 {
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy();
     var intPropDef = GetIntPropDef();
     gridColumn.SetPropDef(intPropDef);
     //---------------Assert Precondition----------------
     Assert.AreSame(typeof(int), intPropDef.PropertyType);
     //---------------Execute Test ----------------------
     var propertyType = gridColumn.GetPropertyType();
     //---------------Test Result -----------------------
     Assert.AreSame(typeof(int), propertyType);
 }
示例#28
0
 public void Test_GetPropType_WhenSetPropDefViaSpy_ShouldReturnSetPropDefsType()
 {
     //This is actually testing an optimisation so that we do not
     // continually have to go refetch the PropDef for the Column
     //---------------Set up test pack-------------------
     var gridColumn = new UIGridColumnSpy();
     IPropDef propDef = GetIntPropDef();
     gridColumn.SetPropDef(propDef);
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var propertyType = gridColumn.GetPropertyType();
     //---------------Test Result -----------------------
     Assert.AreSame(propDef.PropertyType, propertyType);
 }
示例#29
0
 public void Test_LookupList_WhenNullClassDef_ShouldReturnNullLookupList()
 {
     //---------------Set up test pack-------------------
     UIGridColumn gridColumn = new UIGridColumnSpy();
     //---------------Assert Precondition----------------
     Assert.IsNull(gridColumn.ClassDef);
     //---------------Execute Test ----------------------
     ILookupList actualLList = gridColumn.LookupList;
     //---------------Test Result -----------------------
     Assert.IsInstanceOf<NullLookupList>(actualLList );
 }
示例#30
0
        public void TestProtectedSets()
        {
            UIGridColumnSpy column = new UIGridColumnSpy();

            Assert.AreEqual("heading", column.Heading);
            column.SetHeading("newheading");
            Assert.AreEqual("newheading", column.Heading);
            column.SetPropertyName(null);
            Assert.IsNull(column.PropertyName);
            column.SetPropertyName("prop");
            Assert.AreEqual("prop", column.PropertyName);

            Assert.IsNull(column.GridControlType);
            column.SetGridControlType(typeof(DataGridViewTextBoxColumn));
            Assert.AreEqual(typeof(DataGridViewTextBoxColumn), column.GridControlType);

            Assert.IsTrue(column.Editable);
            column.SetEditable(false);
            Assert.IsFalse(column.Editable);

            Assert.AreEqual(100, column.Width);
            column.SetWidth(200);
            Assert.AreEqual(200, column.Width);

            Assert.AreEqual(PropAlignment.left, column.Alignment);
            column.SetAlignment(PropAlignment.right);
            Assert.AreEqual(PropAlignment.right, column.Alignment);
        }
示例#31
0
 public void Test_ClassDef_ShouldReturnUIGridsClassDef()
 {
     //---------------Set up test pack-------------------
     var expectedGridDef = MockRepository.GenerateStub<IUIGrid>();
     IClassDef expectedClassDef = MockRepository.GenerateStub<IClassDef>();
     expectedGridDef.Stub(grid => grid.ClassDef).Return(expectedClassDef);
     IUIGridColumn uiGridColumn = new UIGridColumnSpy();
     //---------------Assert Precondition----------------
     Assert.IsNull(uiGridColumn.ClassDef);
     Assert.IsNotNull(expectedGridDef.ClassDef);
     //---------------Execute Test ----------------------
     uiGridColumn.UIGrid = expectedGridDef;
     var actualClassDef = uiGridColumn.ClassDef;
     //---------------Test Result -----------------------
     Assert.AreSame(expectedClassDef, actualClassDef);
 }
示例#32
0
 public void Test_ClassDef_WhenUIDefNull_ShouldReturnNull()
 {
     //---------------Set up test pack-------------------
     IUIGridColumn uiGridColumn = new UIGridColumnSpy();
     //---------------Assert Precondition----------------
     Assert.IsNull(uiGridColumn.ClassDef);
     Assert.IsNull(uiGridColumn.UIGrid);
     //---------------Execute Test ----------------------
     var actualClassDef = uiGridColumn.ClassDef;
     //---------------Test Result -----------------------
     Assert.IsNull(actualClassDef);
 }