public void TestMethodDefaultMethod3() { List <string> methodsCalled = new List <string>(); BeethovenFactory factory = new BeethovenFactory(); ITestMethods test = factory.Generate <ITestMethods>( new DefaultMethod((methodInfo, _) => methodsCalled.Add(methodInfo.Name))); test.Simple(); test.ReturnValue(); test.WithParameters("as", "wefewf"); test.WithParameters("", null, 5); string b = ""; test.OutAndRef(out string a, ref b, 5); int value = 0; test.Ref(ref value); test.GetMain("klkl", "kklklklkk"); test.NoReturnValue("", ""); CollectionAssert.AreEquivalent(new[] { "Simple", "ReturnValue", "WithParameters", "WithParameters", "OutAndRef", "Ref", "GetMain", "NoReturnValue" }, methodsCalled); }
public void LinkedMethodsTest6() { BeethovenFactory beethovenFactory = new BeethovenFactory(); int calledCount = 0; ValueCheck valueCheck = new ValueCheck(); ITestMethods instance = beethovenFactory.Generate <ITestMethods>( new LinkedMethods(nameof(ITestMethods.NoReturnValue)) .SkipIf(valueCheck, nameof(valueCheck.HasNoValue1)) .Action(delegate { calledCount++; })); instance.NoReturnValue("", "afasf"); instance.NoReturnValue(null, "afasf"); Assert.AreEqual(0, calledCount); instance.NoReturnValue("fdgdf", "afasf"); Assert.AreEqual(1, calledCount); }
public void TestMethodDefaultMethod1() { List <string> methodsCalled = new List <string>(); object LogCall(MethodInfo methodInfo, object[] _) { methodsCalled.Add(methodInfo.Name); return(null); } BeethovenFactory factory = new BeethovenFactory(); ITestMethods test = factory.Generate <ITestMethods>( new DefaultMethod(LogCall)); test.NoReturnValue("asd", "gggggdsss"); CollectionAssert.AreEquivalent(new[] { "NoReturnValue" }, methodsCalled); }