I have this class:
public class MyClass { private static int GetMonthsDateDiff(DateTime d1, DateTime d2) {
Now I am implementing a unit test for it. Since the method is private, I have the following code:
MyClass myClass = new MyClass(); PrivateObject testObj = new PrivateObject(myClass); DateTime fromDate = new DateTime(2015, 1, 1); DateTime toDate = new DateTime(2015, 3, 17); object[] args = new object[2] { fromDate, toDate }; int res = (int)testObj.Invoke("GetMonthsDateDiff", args);
An exception of type "System.MissingMethodException" occurred in mscorlib.dll but was not processed in the user code Additional information: An attempt was made to access a missing item.
What am I doing wrong? Method exists ..
Yakov source share