public void NoMethodProvided_ReturnsDefault(object[]?prms) { var expected = Guid.NewGuid(); var cb = new CallbackInvocation(); var actual = cb.Invoke(prms, expected); Assert.Equal(expected, actual); }
public void FunctionParametersCountMismatch_Throws(Type exceptionType, object[]?prms) { string SomeMethod(object a, object b) => "zzz"; var cb = new CallbackInvocation(); cb.Method = new Func <object, object, string>(SomeMethod); Assert.Throws(exceptionType, () => cb.Invoke(prms)); }
public void ReturnTypeMismatch_Throws() { CallbackInvocation SomeMethod() => null !; var cb = new CallbackInvocation(); cb.Method = new Func <CallbackInvocation>(SomeMethod); Assert.Throws <ArgumentException>(() => cb.Invoke(null, "abc")); }
public void ActionParametersCountMismatch_Throws(Type exceptionType, object[]?prms) { void SomeMethod(object a, object b) { } var cb = new CallbackInvocation(); cb.Method = new Action <object, object>(SomeMethod); Assert.Throws(exceptionType, () => cb.Invoke(prms)); }
public void InvokesActionWithoutParams(object[]?prms) { int invoked = 0; void SomeMethod() => invoked++; var cb = new CallbackInvocation(); cb.Method = new Action(SomeMethod); cb.Invoke(prms); Assert.Equal(1, invoked); }
public void InvokesFunctionWithoutParams(object[]?prms) { var expected = Guid.NewGuid(); int invoked = 0; Guid SomeMethod() { invoked++; return(expected); } var cb = new CallbackInvocation(); cb.Method = new Func <Guid>(SomeMethod); var actual = cb.Invoke <Guid>(prms, default); Assert.Equal(1, invoked); Assert.Equal(expected, actual); }
public void NoMethodProvided_Successful(object[]?prms) { var cb = new CallbackInvocation(); cb.Invoke(prms); }