c# - How do I test with multiple input combinations? -


i have piece of code need test, layered in 3 parts:

  • web api controller
  • persistence/logic layer
  • system calls persistence

it's basic get/post/put/delete call system. instance, in controller have getall method calls get in second layer, in turn calls either sql database method either web api method.

the scenarios: mock second layer , call controller. mock system calls , call second layer. mock system calls , call controller.

for each scenario, have multiple test inputs, each method in controller/second layer.

what best way it? want have little possible code duplication.

i can use datasource attribute on test , have each test layer value select type of mocking do, , each layer value, add test data(input parameters). test data common layer values, mean have duplicate each layer value. have same layer values methods in controller/persistence layer, again duplicate.

i factor out in way layer values, common tests(think of class level values) , have specific input values each method in controller(method level). , each method then, have test in sort of cross product in between general layer values , specific method input values. how achieve that?

thanks, ciprian.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -