mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Unit test that will fail without the fix. * ScrollView must return true after ungrab the mouse to allow the View property run after returned. * Fixes #1999. Prevents the mouseGrabView being executed with a null view. * Added one more assert null check.
36 lines
991 B
C#
36 lines
991 B
C#
using System;
|
|
using System.Reflection;
|
|
|
|
public static class ReflectionTools {
|
|
// If the class is non-static
|
|
public static Object InvokePrivate (Object objectUnderTest, string method, params object [] args)
|
|
{
|
|
Type t = objectUnderTest.GetType ();
|
|
return t.InvokeMember (method,
|
|
BindingFlags.InvokeMethod |
|
|
BindingFlags.NonPublic |
|
|
BindingFlags.Instance |
|
|
BindingFlags.Static,
|
|
null,
|
|
objectUnderTest,
|
|
args);
|
|
}
|
|
// if the class is static
|
|
public static Object InvokePrivate (Type typeOfObjectUnderTest, string method, params object [] args)
|
|
{
|
|
MemberInfo [] members = typeOfObjectUnderTest.GetMembers (BindingFlags.NonPublic | BindingFlags.Static);
|
|
foreach (var member in members) {
|
|
if (member.Name == method) {
|
|
return typeOfObjectUnderTest.InvokeMember (method,
|
|
BindingFlags.NonPublic |
|
|
BindingFlags.Static |
|
|
BindingFlags.InvokeMethod,
|
|
null,
|
|
typeOfObjectUnderTest,
|
|
args);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|