c# - Best Practice for Unit Testing Enum Translator -
what best practice unit testing these kind of methods?
public verificationresultcode translate(int value) { verificationresultcode result; if (enum.isdefined(typeof(verificationresultcode), (int)value)) result = (verificationresultcode)((int)value); else throw new unknownresultreturnfromgatewayexception(); return result; }
verificationresultcode enum type like:
public enum verificationresultcode { bankingnetworkerror = 100, notequal =101, inputformaterror = 102, merchantauthenticationfailed = 103, ... }
we should write single test method each of enum members or write one test method lots of assertions ?!
the code trivial unit test. should unit test behavior depends on verificationresultcode
test translate
function. bigger question why need public translation function instead of encapsulating in objects?
Comments
Post a Comment