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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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."); }
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."); }
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; }
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."); }
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."); }
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; }
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); }
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); }
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); }
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); }
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 ); }
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); }