I am trying to test private static method from a class, in this way:
PrivateType privateTypeObject = new PrivateType(typeof(MyType));
try
{
privateTypeObject.InvokeStatic("myPrivateMethod", 0);
}
catch (ArgumentException) {}
catch {throw; }
The method that I am trying to test it has to throw an argument exception, is the correct, so this is the reason that the catch of the argument exception is empty, because I don't have to do anything.
However, I get an error that says that the exception is not handle. I have try to in the method to throw an Exception, a generic exception, but the problem is the same.
With no private methods in which I can call the method directly, without the PrivateType object, it works as I expect, but in this case I get the error.
How could I catch the exception that I get from the method?
Thanks.
Aucun commentaire:
Enregistrer un commentaire