public void Test_SetValue__WhenUsingRelatedBOProp_ShouldSetValueOnBO() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub <IClassDef>(); classDef.ClassType = typeof(FakeBOWSingleRelationship); var gridColumn = GetGridColumnStub(classDef); gridColumn.PropertyName = "FakeBOW2Props.Prop1"; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); FakeBOW2Props fakeBO = new FakeBOW2Props { Prop1 = RandomValueGen.GetRandomString() }; FakeBOWSingleRelationship fakeBowSingleRelationship = new FakeBOWSingleRelationship { FakeBOW2Props = fakeBO }; //---------------Assert Precondition---------------- Assert.AreSame(classDef, gridColumn.ClassDef); Assert.AreSame(typeof(FakeBOWSingleRelationship), gridColumn.ClassDef.ClassType); Assert.IsNotNullOrEmpty(fakeBO.Prop1); //---------------Execute Test ---------------------- var expectedValue = RandomValueGen.GetRandomString(); propDescriptor.SetValue(fakeBowSingleRelationship, expectedValue); //---------------Test Result ----------------------- Assert.AreEqual(expectedValue, fakeBO.Prop1); }
public void Test_SetValue_WhenComponentNull_ShouldRaiseError() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub <IClassDef>(); classDef.ClassType = typeof(FakeBO); var gridColumn = GetGridColumnStub(classDef); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); object x = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { propDescriptor.SetValue(x, "fdafd"); Assert.Fail("Expected to throw an ArgumentNullException"); } //---------------Test Result ----------------------- catch (ArgumentNullException ex) { StringAssert.Contains("component", ex.ParamName); StringAssert.Contains("Value cannot be null.", ex.Message); } }
public void Test_SetValue_ShouldSetValueOnBO() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub <IClassDef>(); classDef.ClassType = typeof(FakeBO); var gridColumn = GetGridColumnStub(classDef); gridColumn.PropertyName = "FakeBOName"; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); FakeBO fakeBO = new FakeBO { FakeBOName = RandomValueGen.GetRandomString() }; //---------------Assert Precondition---------------- Assert.AreSame(classDef, gridColumn.ClassDef); Assert.AreSame(typeof(FakeBO), gridColumn.ClassDef.ClassType); Assert.IsNotNullOrEmpty(fakeBO.FakeBOName); //---------------Execute Test ---------------------- var expectedValue = RandomValueGen.GetRandomString(); propDescriptor.SetValue(fakeBO, expectedValue); //---------------Test Result ----------------------- Assert.AreEqual(expectedValue, fakeBO.FakeBOName); }
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); }
public void Test_CanResetValue_WhenNotDirty_ShouldReturnFalse() { //---------------Set up test pack------------------- var gridColumn = GetGridColumnStub(); gridColumn.PropertyName = "FakeBOName"; var propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var canResetValue = propDescriptor.CanResetValue(new FakeBO()); //---------------Test Result ----------------------- Assert.IsFalse(canResetValue); }
public void Test_IsReadOnly_WhenNotIsEditable_ShouldReturnTrue() { //---------------Set up test pack------------------- var gridColumn = GetGridColumnStub(); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.IsFalse(gridColumn.Editable); //---------------Execute Test ---------------------- var isReadOnly = propDescriptor.IsReadOnly; //---------------Test Result ----------------------- Assert.IsTrue(isReadOnly, "If gridColumn is not editable propDescriptor.ReadOnly should be true."); }
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); }
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 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); }
public void Test_ShouldSerializeValue_WhenReadOnly_ShouldRetFalse() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); gridColumn.ClassDef.ClassType = typeof(FakeBO); gridColumn.Editable = false; gridColumn.PropertyName = "FakeBOName"; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.IsTrue(propDescriptor.IsReadOnly); //---------------Execute Test ---------------------- var shouldSerializeValue = propDescriptor.ShouldSerializeValue(new FakeBO()); //---------------Test Result ----------------------- Assert.IsFalse(shouldSerializeValue); }
public void Test_ComponentType_ShouldReturnGridColumnsClassDefsClassType() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub <IClassDef>(); classDef.ClassType = typeof(FakeBO); IUIGridColumn gridColumn = GetGridColumnStub(classDef); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.IsNotNull(gridColumn.ClassDef); Assert.IsNotNull(gridColumn.ClassDef.ClassType); //---------------Execute Test ---------------------- var componentType = propDescriptor.ComponentType; //---------------Test Result ----------------------- Assert.AreSame(typeof(FakeBO), componentType); }
public void Test_PropertyType_ShouldReturnPropertyTypeFromColumn() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); Type expectedPropType = typeof(DateTime); gridColumn.Stub(column => column.GetPropertyType()).Return(expectedPropType); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.AreEqual(expectedPropType, gridColumn.GetPropertyType()); //---------------Execute Test ---------------------- var propertyType = propDescriptor.PropertyType; //---------------Test Result ----------------------- Assert.AreEqual(expectedPropType, propertyType); }
public void Test_Alignment_ShouldReturnAlignmentFromColumn() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); var expectedAlignment = RandomValueGen.GetRandomEnum <PropAlignment>();; gridColumn.Alignment = expectedAlignment; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.AreEqual(expectedAlignment, gridColumn.Alignment); //---------------Execute Test ---------------------- var alignment = propDescriptor.Alignment; //---------------Test Result ----------------------- Assert.AreEqual(expectedAlignment, alignment); }
public void Test_Width_ShouldReturnWidthFromColumn() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); var expectedWidth = RandomValueGen.GetRandomInt(0, 33); gridColumn.Width = expectedWidth; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.AreEqual(expectedWidth, gridColumn.Width); //---------------Execute Test ---------------------- var width = propDescriptor.Width; //---------------Test Result ----------------------- Assert.AreEqual(expectedWidth, width); }
public void Test_LookupList_WhenSetOnProp_ShouldReturnList() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); ILookupList expectedLookupList = MockRepository.GenerateStub <ILookupList>(); gridColumn.Stub(column => column.LookupList).Return(expectedLookupList); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.IsNotNull(gridColumn.LookupList); //---------------Execute Test ---------------------- ILookupList lookupList = propDescriptor.LookupList; //---------------Test Result ----------------------- Assert.AreSame(expectedLookupList, lookupList); }
public void Test_CanResetValue_When_ShouldReturnTrue() { //---------------Set up test pack------------------- var gridColumn = GetGridColumnStub(); gridColumn.PropertyName = "FakeBOName"; var propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- FakeBO fakeBO = new FakeBO(); fakeBO.FakeBOName = RandomValueGen.GetRandomString(); var canResetValue = propDescriptor.CanResetValue(fakeBO); //---------------Test Result ----------------------- Assert.IsFalse(canResetValue); }
public void Test_GetValue_ShouldGetValueFromBO() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub<IClassDef>(); classDef.ClassType = typeof(FakeBOWSingleRelationship); var gridColumn = GetGridColumnStub(classDef); gridColumn.PropertyName = "FakeBOW2Props.Prop1"; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); FakeBOW2Props fakeBO = new FakeBOW2Props {Prop1 = RandomValueGen.GetRandomString()}; FakeBOWSingleRelationship fakeBOwSingleRelationship = new FakeBOWSingleRelationship {FakeBOW2Props = fakeBO}; //---------------Assert Precondition---------------- Assert.AreSame(classDef, gridColumn.ClassDef); Assert.AreSame(typeof(FakeBOWSingleRelationship), gridColumn.ClassDef.ClassType); Assert.IsNotNullOrEmpty(fakeBO.Prop1); //---------------Execute Test ---------------------- var actualValue = propDescriptor.GetValue(fakeBOwSingleRelationship); //---------------Test Result ----------------------- Assert.AreEqual(fakeBO.Prop1, actualValue); }
public void Test_SetValue_WhenComponentNotCorrectType_ShouldRaiseError() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub <IClassDef>(); classDef.ClassType = typeof(FakeBO); var gridColumn = GetGridColumnStub(classDef); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { propDescriptor.SetValue(100, "fdafd"); Assert.Fail("Expected to throw an InvalidCastException"); } //---------------Test Result ----------------------- catch (InvalidCastException ex) { StringAssert.Contains("You cannot GetValue since the component is not of type ", ex.Message); } }
public void Test_SetValue_WhenComponentNull_ShouldRaiseError() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub<IClassDef>(); classDef.ClassType = typeof(FakeBO); var gridColumn = GetGridColumnStub(classDef); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); object x = null; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { propDescriptor.SetValue(x, "fdafd"); Assert.Fail("Expected to throw an ArgumentNullException"); } //---------------Test Result ----------------------- catch (ArgumentNullException ex) { StringAssert.Contains("component", ex.ParamName); StringAssert.Contains("Value cannot be null.", ex.Message); } }
public void Test_SetValue_WhenComponentNotCorrectType_ShouldRaiseError() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub<IClassDef>(); classDef.ClassType = typeof(FakeBO); var gridColumn = GetGridColumnStub(classDef); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { propDescriptor.SetValue(100, "fdafd"); Assert.Fail("Expected to throw an InvalidCastException"); } //---------------Test Result ----------------------- catch (InvalidCastException ex) { StringAssert.Contains("You cannot GetValue since the component is not of type ", ex.Message); } }
public void Test_SetValue_ShouldSetValueOnBO() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub<IClassDef>(); classDef.ClassType = typeof(FakeBO); var gridColumn = GetGridColumnStub(classDef); gridColumn.PropertyName = "FakeBOName"; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); FakeBO fakeBO = new FakeBO { FakeBOName = RandomValueGen.GetRandomString() }; //---------------Assert Precondition---------------- Assert.AreSame(classDef, gridColumn.ClassDef); Assert.AreSame(typeof(FakeBO), gridColumn.ClassDef.ClassType); Assert.IsNotNullOrEmpty(fakeBO.FakeBOName); //---------------Execute Test ---------------------- var expectedValue = RandomValueGen.GetRandomString(); propDescriptor.SetValue(fakeBO, expectedValue); //---------------Test Result ----------------------- Assert.AreEqual(expectedValue, fakeBO.FakeBOName); }
public void Test_ComponentType_ShouldReturnGridColumnsClassDefsClassType() { //---------------Set up test pack------------------- IClassDef classDef = MockRepository.GenerateStub<IClassDef>(); classDef.ClassType = typeof (FakeBO); IUIGridColumn gridColumn = GetGridColumnStub(classDef); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.IsNotNull(gridColumn.ClassDef); Assert.IsNotNull(gridColumn.ClassDef.ClassType); //---------------Execute Test ---------------------- var componentType = propDescriptor.ComponentType; //---------------Test Result ----------------------- Assert.AreSame(typeof(FakeBO), componentType); }
public void Test_Alignment_ShouldReturnAlignmentFromColumn() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); var expectedAlignment = RandomValueGen.GetRandomEnum<PropAlignment>();; gridColumn.Alignment = expectedAlignment; PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.AreEqual(expectedAlignment, gridColumn.Alignment); //---------------Execute Test ---------------------- var alignment = propDescriptor.Alignment; //---------------Test Result ----------------------- Assert.AreEqual(expectedAlignment, alignment); }
public void Test_LookupList_WhenSetOnProp_ShouldReturnList() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); ILookupList expectedLookupList = MockRepository.GenerateStub<ILookupList>(); gridColumn.Stub(column => column.LookupList).Return(expectedLookupList); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.IsNotNull(gridColumn.LookupList); //---------------Execute Test ---------------------- ILookupList lookupList = propDescriptor.LookupList; //---------------Test Result ----------------------- Assert.AreSame(expectedLookupList, lookupList); }
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); }
public void Test_PropertyType_ShouldReturnPropertyTypeFromColumn() { //---------------Set up test pack------------------- IUIGridColumn gridColumn = GetGridColumnStub(); Type expectedPropType = typeof (DateTime); gridColumn.Stub(column => column.GetPropertyType()).Return(expectedPropType); PropertyDescriptorPropDef propDescriptor = new PropertyDescriptorPropDef(gridColumn); //---------------Assert Precondition---------------- Assert.AreEqual(expectedPropType, gridColumn.GetPropertyType()); //---------------Execute Test ---------------------- var propertyType = propDescriptor.PropertyType; //---------------Test Result ----------------------- Assert.AreEqual(expectedPropType, propertyType); }