Beispiel #1
0
        public void NoMethodProvided_ReturnsDefault(object[]?prms)
        {
            var expected = Guid.NewGuid();
            var cb       = new CallbackInvocation();

            var actual = cb.Invoke(prms, expected);

            Assert.Equal(expected, actual);
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        public void ReturnTypeMismatch_Throws()
        {
            CallbackInvocation SomeMethod() => null !;

            var cb = new CallbackInvocation();

            cb.Method = new Func <CallbackInvocation>(SomeMethod);

            Assert.Throws <ArgumentException>(() => cb.Invoke(null, "abc"));
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        public void NoMethodProvided_Successful(object[]?prms)
        {
            var cb = new CallbackInvocation();

            cb.Invoke(prms);
        }