public void GenericSimpleTest2() { BeethovenFactory beethovenFactory = new BeethovenFactory(); IGenericMethods instance = beethovenFactory.Generate <IGenericMethods>( FuncMethod.Create("Simple", () => "abcd"), FuncMethod.Create("Simple", () => 5), FuncMethod.Create("Simple", () => (short)0)); Assert.AreEqual(5, instance.Simple <int>()); Assert.AreEqual(0, instance.Simple <short>()); Assert.AreEqual("abcd", instance.Simple <string>()); }
public void GenericSimpleTest4() { GenericMethods2 genericMethods2 = new GenericMethods2(); BeethovenFactory beethovenFactory = new BeethovenFactory(); IGenericMethods instance = beethovenFactory.Generate <IGenericMethods>( FuncMethod.Create("Simple", genericMethods2.SimpleString), FuncMethod.Create("Simple", genericMethods2.SimpleInt), genericMethods2); Assert.AreEqual(5, instance.Simple <int>()); Assert.AreEqual("abcd", instance.Simple <string>()); }
public void TestMethodFallbackMethod1() { int callCount = 0; ITestMethods test = TypeDefinition <ITestMethods> .Create( ActionMethod.Create("Simple", () => callCount++).CreateFallback(), FuncMethod.Create("ReturnValue", () => 5) ) .CreateNew(); Assert.AreEqual(5, test.ReturnValue()); Assert.AreEqual(0, callCount); test.Simple(); Assert.AreEqual(1, callCount); }