Example #1
0
        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);
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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);
        }
Example #4
0
        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__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_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);
 }