Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Reflection;
- using NUnit.Framework;
- namespace WebApplication2
- {
- public class Class1
- {
- public void callMethod(string method)
- {
- object classInstance = Activator.CreateInstance(typeof(THE_INHERITED_CLASS), null);
- MethodInfo methodInfo = classInstance.GetType().GetMethod(method);
- methodInfo.Invoke(classInstance, null);
- }
- }
- public class THE_INHERITED_CLASS
- {
- public void MyMethod()
- {
- Console.WriteLine("MyMethod Called");
- }
- }
- [TestFixture]
- public class Test
- {
- [Test]
- public void TestItWorks()
- {
- Class1 class1 = new Class1();
- class1.callMethod("MyMethod");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement