Example #1
0
        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);
        }
Example #2
0
        public void TestMethod1()
        {
            var f = new FuncHost();

            var expect = "yoo";
            f.Function("foo", () => { return expect; });
            var result = f.Invoke("foo");

            Assert.AreEqual(expect, result);
        }
Example #3
0
        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());
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }