public void TestUnbindWithObject() { new Application().Bootstrap(); var cls = new TestContainerClass(); App.BindMethod("Helloworld.Func1", cls); App.BindMethod("Helloworld.Func2", cls); var cls2 = new TestContainerClass(); App.BindMethod("Helloworld2.Func1", cls2); App.BindMethod("Helloworld2.Func2", cls2); App.UnbindMethod(cls); App.UnbindMethod(cls); // double unbind test App.UnbindMethod("UnknowMethod"); ExceptionAssert.Throws <RuntimeException>(() => { App.Invoke("Helloworld.Func1", 1000, 2000); }); ExceptionAssert.Throws <RuntimeException>(() => { App.Invoke("Helloworld.Func2", 1000, 2000); }); Assert.AreEqual(1000, App.Invoke("Helloworld2.Func1", 1000, 2000)); Assert.AreEqual((float)2000, App.Invoke("Helloworld2.Func2", 1000, 2000)); }
public void TestBindExcistsMethod() { new Application(); var cls = new TestContainerClass(); App.BindMethod("Helloworld.Func1", cls); ExceptionAssert.Throws <RuntimeException>(() => { App.BindMethod("Helloworld.Func1", cls); }); }
public void TestContainerMethodContextual() { new Application(); App.Instance("@input", 1000); App.Instance("@input2", 2000); var cls = new TestContainerClass(); App.BindMethod("Helloworld.Func1", cls).Needs("@input").Given("@input2"); App.BindMethod("Helloworld.Func2", cls) .Needs("@input").Given("@input2") .Needs("@input2").Given("@input");; Assert.AreEqual(2000, App.Invoke("Helloworld.Func1")); Assert.AreEqual((float)1000, App.Invoke("Helloworld.Func2")); }
public void TestFlush() { new Application(); var cls = new TestContainerClass(); var bind1 = App.BindMethod("Helloworld.Func1", cls); var bind2 = App.BindMethod("Helloworld.Func2", cls); App.Handler.Flush(); ExceptionAssert.Throws <RuntimeException>(() => { App.Invoke("Helloworld.Func1", 1000, 2000); }); ExceptionAssert.Throws <RuntimeException>(() => { App.Invoke("Helloworld.Func2", 1000, 2000); }); App.UnbindMethod(cls); App.UnbindMethod(cls); // double unbind test App.UnbindMethod(bind1); App.UnbindMethod(bind2); }