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_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); }