Testing private methods in a C# can be a bit challenging. This is just to remember what's needed.
[TestClass]
private MyUnit _myUnit;
[TestMethod]
var testMyUnit = new PrivateObject(_myUnit);
...
var result = (List<string>)testMyUnit.Invoke("MyMethod", parameter1, parameter2);
Assert.AreEqual(2, result.Count());
Original method (to be tested) in MyUnit:
private List<string> MyMethod(string sv1, string sv2)
{
List<string> retval = new List<string>
{
sv1,
sv2
};
return retval;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.