Example #1
0
        public void Test_SetPropertyValue_WithInterface()
        {
            //---------------Set up test pack-------------------
            ClassWithProperties classWithProperties = new ClassWithProperties();
            IMyInterface        newValue            = new MyInterfaceClass();

            //---------------Assert Precondition----------------
            Assert.IsNull(classWithProperties.InterfaceProperty);
            //---------------Execute Test ----------------------
            ReflectionUtilities.SetPropertyValue(classWithProperties, "InterfaceProperty", newValue);
            //---------------Test Result -----------------------
            Assert.AreSame(newValue, classWithProperties.InterfaceProperty);
        }
 public void Test_SetPropertyValue_ToNull_WithInterface()
 {
     //---------------Set up test pack-------------------
     ClassWithProperties classWithProperties = new ClassWithProperties();
     IMyInterface oldValue = new MyInterfaceClass();
     classWithProperties.InterfaceProperty = oldValue;
     //---------------Assert Precondition----------------
     Assert.AreSame(oldValue, classWithProperties.InterfaceProperty);
     //---------------Execute Test ----------------------
     ReflectionUtilities.SetPropertyValue(classWithProperties, "InterfaceProperty", null);
     //---------------Test Result -----------------------
     Assert.IsNull(classWithProperties.InterfaceProperty);
 }