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 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 GenericSimpleTest1() { GenericMethods genericMethods = new GenericMethods(); BeethovenFactory beethovenFactory = new BeethovenFactory(); IGenericMethods instance = beethovenFactory.Generate <IGenericMethods>(genericMethods); List <string> calledMethods = new List <string>(); genericMethods.MethodCalled += s => calledMethods.Add(s); Assert.AreEqual(5, instance.Simple <int>()); Assert.AreEqual(0, instance.Simple <short>()); Assert.AreEqual("abcd", instance.Simple <string>()); CollectionAssert.AreEquivalent(new[] { "Simple", "Simple", "Simple" }, calledMethods); }
public void LinkedMethodsTest12() { BeethovenFactory beethovenFactory = new BeethovenFactory(); IGenericMethods instance = beethovenFactory.Generate <IGenericMethods>( LinkedMethodsReturnValue.Create <IGenericMethods>(nameof(IGenericMethods.Simple)) .Func(() => true) .FlowControl(() => false) .Func(() => false)); Assert.AreEqual(true, instance.Simple <bool>()); }