public void Test_SetValue_WhenComponentNotCorrectType_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            var propertyInfo   = typeof(FakeBO).GetProperty("FakeBOName");
            var propDescriptor = new PropertyDescriptorPropInfo(propertyInfo);

            //---------------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-------------------
            var    propertyInfo   = typeof(FakeBO).GetProperty("FakeBOName");
            var    propDescriptor = new PropertyDescriptorPropInfo(propertyInfo);
            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-------------------

            var propertyInfo     = typeof(FakeBO).GetProperty("FakeBOName");
            var initialPropValue = GetRandomString();
            var fakeBO           = new FakeBO {
                FakeBOName = initialPropValue
            };
            var propDescriptor = new PropertyDescriptorPropInfo(propertyInfo);


            //---------------Assert Precondition----------------
            Assert.AreEqual(initialPropValue, propertyInfo.GetValue(fakeBO, null));
            Assert.AreEqual(initialPropValue, fakeBO.FakeBOName);
            //---------------Execute Test ----------------------
            var expectedNewPropValue = GetRandomString();

            propDescriptor.SetValue(fakeBO, expectedNewPropValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedNewPropValue, fakeBO.FakeBOName);
        }
        public void Test_SetValue_WhenComponentNull_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            var propertyInfo = typeof(FakeBO).GetProperty("FakeBOName");
            var propDescriptor = new PropertyDescriptorPropInfo(propertyInfo);
            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-------------------
     var propertyInfo = typeof(FakeBO).GetProperty("FakeBOName");
     var propDescriptor = new PropertyDescriptorPropInfo(propertyInfo);
     //---------------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-------------------

            var propertyInfo = typeof(FakeBO).GetProperty("FakeBOName");
            var initialPropValue = GetRandomString();
            var fakeBO = new FakeBO { FakeBOName = initialPropValue };
            var propDescriptor = new PropertyDescriptorPropInfo(propertyInfo);

            
            //---------------Assert Precondition----------------
            Assert.AreEqual(initialPropValue, propertyInfo.GetValue(fakeBO, null));
            Assert.AreEqual(initialPropValue, fakeBO.FakeBOName);
            //---------------Execute Test ----------------------
            var expectedNewPropValue = GetRandomString();
            propDescriptor.SetValue(fakeBO, expectedNewPropValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedNewPropValue, fakeBO.FakeBOName);
        }