[Test] public void QueryableMemberIsInvoked() { var queryable = new QueryableClass(); RuntimeMember method = RuntimeType.GetInstance(new TypedValue(queryable), new IdentifierName("dynamic"), 1); TypedValue result = method.Invoke(new object[] { "stuff" }); Assert.AreEqual("dynamicstuff", result.Value); }
[Test] public void MethodWithParmsIsInvoked() { RuntimeMember method = RuntimeType.GetInstance(new TypedValue(instance), "methodwithparms", 1); Assert.IsNotNull(method); TypedValue result = method.Invoke(new object[] { "input" }); Assert.AreEqual("sampleinput", result.Value.ToString()); }
[Test] public void MethodWithUnderscoresIsInvoked() { RuntimeMember method = RuntimeType.GetInstance(new TypedValue(instance), "methodwithunderscores", 0); Assert.IsNotNull(method); TypedValue result = method.Invoke(new object[] {}); Assert.AreEqual("samplereturn", result.Value.ToString()); }
[Test] public void IndexerIsInvoked() { RuntimeMember method = RuntimeType.GetInstance(new TypedValue(instance), "anything", 0); Assert.IsNotNull(method); TypedValue result = method.Invoke(new object[] {}); Assert.AreEqual("indexanything", result.Value); Assert.AreEqual(typeof(string), result.Type); }
[Test] public void MethodWithReturnIsInvoked() { RuntimeMember method = RuntimeType.GetInstance(new TypedValue(instance), "methodnoparms", 0); Assert.IsNotNull(method); TypedValue result = method.Invoke(new object[] {}); Assert.AreEqual("samplereturn", result.Value.ToString()); Assert.AreEqual(typeof(string), result.Type); }
[Test] public void VoidMethodIsInvoked() { RuntimeMember method = RuntimeType.GetInstance(new TypedValue(instance), "voidmethod", 0); Assert.IsNotNull(method); TypedValue result = method.Invoke(new object[] {}); Assert.AreEqual(null, result.Value); Assert.AreEqual(typeof(void), result.Type); }
[Test] public void PropertySetAndGetIsInvoked() { RuntimeMember method = RuntimeType.GetInstance(new TypedValue(instance), "property", 1); Assert.IsNotNull(method); TypedValue result = method.Invoke(new object[] { "stuff" }); Assert.AreEqual(null, result.Value); Assert.AreEqual(typeof(void), result.Type); method = RuntimeType.GetInstance(new TypedValue(instance), "property", 0); Assert.IsNotNull(method); result = method.Invoke(new object[] {}); Assert.AreEqual("stuff", result.Value.ToString()); Assert.AreEqual(typeof(string), result.Type); }
RuntimeMember GetMethod(string memberName, int count) { return(RuntimeType.GetInstance(new TypedValue(instance), new IdentifierName(memberName), count)); }