public void TestMethodCache() { var f = new FuncHost("",cacheAsKey: "cache"); var expect1 = "v1"; f.Function("hello", () => { return expect1; }); var result1 = f.Invoke("hello"); var expect2 = "v2"; f.Function("hello", () => { return expect2; }); var result2 = f.Invoke("hello"); Assert.AreEqual(expect1, result1); }
public void TestMethod2() { var f = new FuncHost(); var functionName = "someFunction"; f.Function(functionName, () => { return ""; }); var result = f.Render(); Assert.IsTrue(result.ToString().Contains(functionName)); }
public void TestMethod1() { var f = new FuncHost(); var expect = "yoo"; f.Function("foo", () => { return expect; }); var result = f.Invoke("foo"); Assert.AreEqual(expect, result); }
public void TestMethodDeserialize() { var f = new FuncHost(); var functionName = "someFunction"; f.Function<Foo>(functionName, (param) => { return param.Name; }); var result = f.Invoke("someFunction", "{Name:'Jonas'}"); Assert.AreEqual("Jonas", result.ToString()); }
public void TestMethodDeserializeComplex() { var f = new FuncHost(); var functionName = "someFunction"; var parameter = new Foo { Name = "Jonas" }; f.Function<dynamic>(functionName, (param) => { return param.Name; }); var result = f.InvokeAndSerialize("someFunction", "{Name:'Jonas'}"); Assert.AreEqual("\"" + parameter.Name + "\"", result); }
public void TestMethodInt() { var f = new FuncHost(); var expect = "yoo"; f.Function<int>("foo", (i) => { return (i+i).ToString(); }); var result = f.Invoke("foo","100"); Assert.AreEqual("200", result); }
public void TestMethodStringParameter() { var f = new FuncHost(); var expect = "yoo"; f.Function("foo", (param) => { return param; }); var result = f.Invoke("foo", expect); Assert.AreEqual(expect, result); }
public void TestMethodSerialize() { var f = new FuncHost(); var expect = "yoo"; f.Function("foo", () => { return new Foo { Name = expect }; }); var result = f.InvokeAndSerialize("foo", ""); Assert.AreEqual("{\"Name\":\"yoo\"}", result); }
public void TestMethodNoCache() { var f = new FuncHost("", ""); var expect = "v1"; f.Function("hello", () => { return expect; }); var result1 = f.Invoke("hello"); expect = "v2"; f.Function("hello", () => { return expect; }); var result2 = f.Invoke("hello"); Assert.AreEqual(expect, result2); }