public void TestPrivatePropertyGet() { var reflector = new TypeReflector(typeof(TestClass)); var property = reflector.GetProperty("BirthDate"); var val = PropertyCache.GetInvoker<TestClass, DateTime>(_instance, property); var result = val.GetValue(); Assert.AreEqual(result, DateTime.MinValue); }
public void TestPrivatePropertySet() { var reflector = new TypeReflector(typeof(TestClass)); var property = reflector.GetProperty("SocialNumber"); var val = PropertyCache.GetInvoker<TestClass, string>(_instance, property); val.SetValue("123456789"); var result = val.GetValue(); Assert.AreEqual(result, "123456789"); }
public void TestPrivateMethodInvoke() { _instance.Name = "Scott"; var reflector = new TypeReflector(typeof(TestClass)); var method = reflector.GetMethod("HelloPerson"); var val = MethodInvokerCache.GetInvoker<TestClass, string>(_instance, method); var result = val.Invoke(null); Assert.AreEqual(result, "Hello Scott"); }