Esempio n. 1
0
        public void InvokeGenericRegularInstanceMethodWithNoParametersTest1()
        {
            //instance of the class that contains this method
            var InstanceOfObjectWithClass = new InvokeRegularMethod();

            //let's go invoke this method dynamically (static method)
            Assert.Equal(InvokeRegularMethod.InvokeStaticMethodResult, new GenericInstanceMethodFinder(InstanceOfObjectWithClass, nameof(InvokeRegularMethod.InvokeInstanceGenericMethodWithNoParameter), new Type[] { typeof(string) }, null).FindMethodToInvoke().Invoke(InstanceOfObjectWithClass, null));
        }
Esempio n. 2
0
        public void InvokeRegularInstanceMethodWithClassObjectAndNoParametersTest1()
        {
            //create the instance of the class
            var InstanceOfClass = new InvokeRegularMethod();

            //let's go invoke this method dynamically (static method)
            Assert.Equal(InvokeRegularMethod.InvokeStaticMethodResult, new NonGenericInstanceMethodFinder(InstanceOfClass, nameof(InvokeRegularMethod.InvokeInstanceMethod), null).FindMethodToInvoke().Invoke(InstanceOfClass, null));
        }
Esempio n. 3
0
        public void InvokeRegularInstanceMethodWithClassObjectWithParametersTest1()
        {
            //number to pass in
            const int NumberToAdd = 10;

            //create the instance of the class
            var InstanceOfClass = new InvokeRegularMethod();

            //let's go invoke this method dynamically (static method)
            Assert.Equal(InvokeRegularMethod.InvokeStaticMethodResult + NumberToAdd, new NonGenericInstanceMethodFinder(InstanceOfClass, nameof(InvokeRegularMethod.InvokeInstanceMethodWithParameter), new Type[] { typeof(int) }).FindMethodToInvoke().Invoke(InstanceOfClass, new object[] { NumberToAdd }));
        }
Esempio n. 4
0
        public void InvokeGenericRegularInstanceMethodWithParametersTest1()
        {
            //instance of the class that contains this method
            var InstanceOfObjectWithClass = new InvokeRegularMethod();

            //number to pass in
            const int NumberToAdd = 10;

            var Parameters = new List <GenericTypeParameter>
            {
                new GenericTypeParameter(typeof(int), false)
            };

            //let's go invoke this method dynamically (static method)
            Assert.Equal(InvokeRegularMethod.InvokeStaticMethodResult + NumberToAdd, new GenericInstanceMethodFinder(InstanceOfObjectWithClass, nameof(InvokeRegularMethod.InvokeInstanceGenericMethodWithParameters), new Type[] { typeof(string) }, Parameters).FindMethodToInvoke().Invoke(InstanceOfObjectWithClass, new object[] { NumberToAdd }));
        }