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("FindOne", BindingFlags.Static | BindingFlags.Public, null, new []{typeof(object)}, null);
- Assert.IsNotNull(methodInfo);
- Assert.AreEqual("FindOne", methodInfo.Name);
- Assert.AreEqual("DateTime", methodInfo.MakeGenericMethod(typeof(DateTime)).Invoke(null, new object[] {null}));
- }
- }
- public class GenericMethodContainer
- {
- public static string FindOne<T>(string arg)
- {
- return typeof(T).Name;
- }
- public static string FindOne<T>(object arg)
- {
- return typeof(T).Name;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement