Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Reflection;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- namespace tacGenericTest
- {
- [TestClass]
- public class GetMethodTest
- {
- [TestMethod]
- public void FindMethodTest()
- {
- var methodInfo = typeof (GenericMethodContainer).GetMethod("Test", BindingFlags.Static | BindingFlags.Public);
- Assert.IsNotNull(methodInfo);
- Assert.AreEqual("Test", methodInfo.Name);
- Assert.AreEqual("DateTime", methodInfo.MakeGenericMethod(typeof(DateTime)).Invoke(null, new object[0]));
- }
- }
- public class GenericMethodContainer
- {
- public static string Test<T>()
- {
- return typeof(T).Name;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement