public void ExpandoMethodsTest() { dynamic tNew = new ExpandoObject(); tNew.Action1 = new Action(Assert.Fail); tNew.Action2 = new Action <bool>(Assert.IsFalse); tNew.Action3 = new Func <string>(() => "test"); ISimpeleClassMeth tActsLike = Impromptu.ActLike <ISimpeleClassMeth>(tNew); AssertException <AssertionException>(tActsLike.Action1); AssertException <AssertionException>(() => tActsLike.Action2(true)); Assert.AreEqual("test", tActsLike.Action3()); }
public void DictionaryMethodsTestWithPropertyAccess() { dynamic tNew = new Dictionary(); tNew.PropCat = "Cat-"; tNew.Action1 = new Action(Assert.Fail); tNew.Action2 = new Action <bool>(Assert.IsFalse); tNew.Action3 = new ThisFunc <string>(@this => @this.PropCat + "test"); ISimpeleClassMeth tActsLike = Impromptu.ActLike <ISimpeleClassMeth>(tNew); AssertException <AssertionException>(tActsLike.Action1); AssertException <AssertionException>(() => tActsLike.Action2(true)); Assert.AreEqual("Cat-test", tActsLike.Action3()); }
public void AnnonMethodsTest() { var tNew = new { Action1 = new Action(Assert.Fail), Action2 = new Action <bool>(Assert.IsFalse), Action3 = new Func <string>(() => "test"), }; ISimpeleClassMeth tActsLike = tNew.ActLike <ISimpeleClassMeth>(); AssertException <AssertionException>(tActsLike.Action1); AssertException <AssertionException>(() => tActsLike.Action2(true)); Assert.AreEqual("test", tActsLike.Action3()); }