c# - Is there a common way to test complex functions with NUnit? -


is there common way test complex functions several parameters nunit? think hard or impossible test every condition.

i'm afraid combination of parameters isn't expected in function not expected in test.

so expected condition not fail unexpected.

thanks

this shouldn't hard test @ all. if is, method isn't designed testability, , code smell tells you need refactor it.

i tend write tests in these cases follows (others may have better suggestions):

  1. does work intended when appropriate parameters passed?
  2. does throw expected exceptions when think should? (argumentnullexception, etc.)
  3. for each parameter, happens when pass null, minimum , maximum. (this can extensive, depending on number of arguments.)

if method takes lot of parameters, consider refactoring take object information on it, can encapsulate rules in object, , pass object method.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -