public void GetValue_instance_not_null() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var instance = new TestClass { Name = "noName" }; var result = runtimeDynamicType.GetValue(instance, "Name"); Assert.AreEqual(instance.Name, result); }
public void TryGetValue_instance_not_null_invalid_property() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var instance = new TestClass { Name = "NoName" }; var result = runtimeDynamicType.TryGetValue(instance, "nothing"); Assert.AreEqual(Undefined.Value, result); }
public void TrySetValue_instance_null_returns_false() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var result = runtimeDynamicType.TrySetValue(null, string.Empty, null); Assert.AreEqual(false, result); }
public void SetValue_valid_instance() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var instance = new TestClass(); const string value = "someName"; runtimeDynamicType.SetValue(instance, "Name", value); Assert.AreEqual(value, instance.Name); }
public void SetValue_instance_null_throws() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); runtimeDynamicType.SetValue(null, string.Empty, null); }
public void TryGetValue_instance_null_returns_undefined() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var result = runtimeDynamicType.TryGetValue(null, string.Empty); Assert.AreEqual(Undefined.Value, result); }
public void RuntimeDynamicType_constructor_test() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var type = runtimeDynamicType.Type; Assert.AreEqual(type, typeof(TestClass)); }
public void GetDynamicProperty_throwOnNotFound() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); object instance = new TestClass(); runtimeDynamicType.GetValue(instance, string.Empty); }
public void TryInvoke_instance_non_existing_method_returns_undefined() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var list = new List<string>(); object instance = new TestClass(); var ienum = (IEnumerable<object>)list; var result = runtimeDynamicType.TryInvoke(instance, "blah-blah", ienum); Assert.AreEqual(Undefined.Value, result); }
public void TryInvoke_instance_null_returns_undefined() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var list = new List<string>(); var ienum = (IEnumerable<object>)list; var result = runtimeDynamicType.TryInvoke(null, string.Empty, ienum); Assert.AreEqual(Undefined.Value, result); }
public void Invoke_instance_null_throws() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var list = new List<string>(); var ienum = (IEnumerable<object>)list; var result = runtimeDynamicType.Invoke(null, string.Empty, ienum); Assert.AreEqual(null, result); }
public void Invoke_valid_instance() { var runtimeDynamicType = new RuntimeDynamicType(typeof(TestClass)); var instance = new TestClass { Name = "someName" }; var list = new List<string> { "IC" }; var ienum = (IEnumerable<object>)list; var result = runtimeDynamicType.Invoke(instance, "ComputeFullName", ienum); Assert.AreEqual(instance.ComputeFullName("IC"), result); }