Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integration test and unit test (WEB API mvc 4)

how does the integration test and unit test relevant in doing testing on APIController? and how can i mock the repository while creating the webrequest in the integration test so it does not make an actual query to the database?

like image 781
user384080 Avatar asked Aug 13 '12 02:08

user384080


1 Answers

You can use the Self Hosting functionality to start up the controllers and use the OpenAsync().ContinueWith(t => { /* ... */ }) function to run your tests. You'll want to override the Configuration.DependencyResolver and override the IHttpControllerActivator so that you can specify your own mock implementation (e.g. you can use Ninject to retrieve the specific controller already bound up with a mock implementation).

like image 119
Chris Avatar answered Oct 12 '22 20:10

Chris