public void TestCanHandleSimpleTestWithLoadedType() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "noArg", "noArg"); var r = CanHandle(new TypeHandlerReplacementCall(), typeof(SimpleTest)); Assert.IsTrue(r, "everything should have been loaded"); }
public void TestSameMethodsDifferentArgTypes() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "oneArg", "oneArg", new Tuple <string, string>[] { new Tuple <string, string>(typeof(float).FullName, "float") }); var e = Expression.Call(null, typeof(SimpleTest).GetMethod("oneArg"), new Expression[] { Expression.Constant((int)10) }); var gc = new GeneratedCode(); var context = new CodeContext(); var r = CodeMethodCall(new TypeHandlerReplacementCall(), e, gc); }
public void TestRigthClassMethodBadArgsDefined() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "noArg", "noArg", new Tuple <string, string>[] { new Tuple <string, string>(typeof(int).FullName, "int") }); var e = Expression.Call(null, typeof(SimpleTest).GetMethod("noArg")); var gc = new GeneratedCode(); var context = new CodeContext(); var r = CodeMethodCall(new TypeHandlerReplacementCall(), e, gc); }
public void TestRigthClassMethodBadArgs() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "oneArg", "oneArg"); var e = Expression.Call(null, typeof(SimpleTest).GetMethod("oneArg"), new Expression[] { Expression.Constant((int)1) }); var gc = new GeneratedCode(); var context = new CodeContext(); var r = CodeMethodCall(new TypeHandlerReplacementCall(), e, gc); }
public void TestRightClassBadMethod() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "noArgDude", "noArg"); var e = Expression.Call(null, typeof(SimpleTest).GetMethod("noArg")); var gc = new GeneratedCode(); var context = new CodeContext(); var r = CodeMethodCall(new TypeHandlerReplacementCall(), e, gc); }
public void TestCallWithArgs() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "oneArg", "oneArg", new Tuple <string, string>[] { new Tuple <string, string>(typeof(int).FullName, "int") }); var e = Expression.Call(null, typeof(SimpleTest).GetMethod("oneArg"), new Expression[] { Expression.Constant((int)10) }); var gc = new GeneratedCode(); var context = new CodeContext(); var r = CodeMethodCall(new TypeHandlerReplacementCall(), e, gc); Assert.AreEqual("oneArg((int)10)", r.RawValue, "uncorrected coded method argument"); }
public void TestIncludes() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "noArg", "noArg", null, new string[] { "cmath" }); var e = Expression.Call(null, typeof(SimpleTest).GetMethod("noArg")); var gc = new GeneratedCode(); var context = new CodeContext(); var result = CodeMethodCall(new TypeHandlerReplacementCall(), e, gc); Assert.AreEqual(1, gc.IncludeFiles.Count(), "# include files"); Assert.AreEqual("cmath", gc.IncludeFiles.First(), "include filename"); }
public void TestNoArg() { TypeHandlerReplacementCall.AddMethod("SimpleTest", "noArg", "noArg"); var e = Expression.Call(null, typeof(SimpleTest).GetMethod("noArg")); var gc = new GeneratedCode(); var context = new CodeContext(); var result = CodeMethodCall(new TypeHandlerReplacementCall(), e, gc); Assert.AreEqual(typeof(double), result.Type, "the type that came back isn't right"); Assert.AreEqual("noArg()", result.RawValue, "raw translation incorrect"); }