Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/Utils/TestUtils.cs @ 15554

Last change on this file since 15554 was 15554, checked in by rhanghof, 6 years ago

#2817:

  • Unittests
  • Bugfixes on the line projection based extreme point creation method
File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Text;
6using System.Threading.Tasks;
7
8namespace HeuristicLab.Problems.BinPacking._3D.Utils.Tests {
9  internal static class TestUtils {
10    public static object InvokeStaticMethod(Type type, string methodName, object[] parameters) {
11      var method = type.GetMethod(methodName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
12      return method.Invoke(null, parameters);
13    }
14
15    /// <summary>
16    /// Invokes a private method of an given object by using reflection
17    /// </summary>
18    /// <param name="type"></param>
19    /// <param name="o"></param>
20    /// <param name="methodName"></param>
21    /// <param name="parameters"></param>
22    /// <returns></returns>
23    public static object InvokeMethod(Type type, object o, string methodName, object[] parameters) {
24      var method = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
25      return method.Invoke(o, parameters);
26    }
27  }
28}
Note: See TracBrowser for help on using the repository browser.