Exemplo n.º 1
0
        public void MethodAccessors_InvokeFuncMethod_MethodWithParamsIsCalled()
        {
            var testObj    = new MethodAccessorsTestClass();
            var funcResult = testObj.InvokeFuncMethod(nameof(MethodAccessorsTestClass.Return42TimesFactor), new object[] { 3 });

            Assert.Equal(126, funcResult);
        }
Exemplo n.º 2
0
        public void MethodAccessors_InvokeFuncMethod_MethodWithoutParamsIsCalled()
        {
            var testObj    = new MethodAccessorsTestClass();
            var funcResult = testObj.InvokeFuncMethod(nameof(MethodAccessorsTestClass.Return42), null);

            Assert.Equal(42, funcResult);
        }
Exemplo n.º 3
0
        public void MethodAccessors_InvokeFuncMethodT_InvalidReturnType()
        {
            var testObj = new MethodAccessorsTestClass();

            Assert.Throws <InvalidCastException>(() => testObj.InvokeFuncMethod <string>(nameof(MethodAccessorsTestClass.Return42), null));
        }
Exemplo n.º 4
0
        public void MethodAccessors_InvokeFuncMethodT_MethodDoesNotExist(string invalidMethodName)
        {
            var testObj = new MethodAccessorsTestClass();

            Assert.Throws <ArgumentException>(() => testObj.InvokeFuncMethod <int>(invalidMethodName, null));
        }