I'm not sure what I should ask about it here, but here we go, and the module is testing a private static method, which has as a parameter short. I get a MissingMethodException only when this parameter is 0.
I am using VS 2010 SP1 to target Framework 4 (full), here is the minimum code to reproduce this error (we update the VB6 code, so not rough):
[DataContract] public enum NotificationResult { [EnumMember] Success, [EnumMember] StoredError, [EnumMember] InvalidId, [EnumMember] OperationError, } public sealed class NotificationContext { private static NotificationResult GetExecuteResult(short result) { NotificationResult executeResult; switch (result) { case 0: executeResult = NotificationResult.Success; break; case 1: executeResult = NotificationResult.StoredError; break; case 2: executeResult = NotificationResult.InvalidId; break; default: executeResult = NotificationResult.OperationError; break; } return executeResult; } }
This is how I test the code:
PrivateType privateHelperType = new PrivateType(typeof(NotificationContext)); var actual = (NotificationResult)privateHelperType.InvokeStatic( "GetExecuteResult", (short)1); var actual2 = (NotificationResult)privateHelperType.InvokeStatic( "GetExecuteResult", (short)0);
In the first call I get the expected result, in the second call I get an exception (I added a short opinion that perhaps the exception was because he did not find the method with int as a parameter).
Can anyone reproduce the behavior? Am I doing something wrong?
Thanks for your help.
source share