Hey guys, I have this problem and really could use some help/explination. I'm fairly new to Umbraco, unit testing and Mocking so bear with me please. I have this simple method in my UmbracoApiController that checks if a certain DocType allows variations. Now the problem lies with trying to test this method. I always recieve a nullReferenceException. I think it probably has something to do with bad Mocking, because I never seem te get the right data.
If someone can point me in the right direction, that would be greatly appreciated.
I am wondering if you guys do unit test your controllers and if it is common practise in a TTD environment.
What I have are skinny controllers that basically call on to the business layer for logic and data and then populate a local ViewModel to pass to the view.
I do unit test the business layer but I wonder if testing these skinny controllers still make sense or its really not necessary unless you have a fat controller with a lot of logic in it.
UnitTesting UmbracoApiController NullReferenceException
Hey guys, I have this problem and really could use some help/explination. I'm fairly new to Umbraco, unit testing and Mocking so bear with me please. I have this simple method in my UmbracoApiController that checks if a certain DocType allows variations. Now the problem lies with trying to test this method. I always recieve a nullReferenceException. I think it probably has something to do with bad Mocking, because I never seem te get the right data. If someone can point me in the right direction, that would be greatly appreciated.
This is my API Controller:
This is my test:
Kind regards,
Gerly
Hello,
I am wondering if you guys do unit test your controllers and if it is common practise in a TTD environment.
What I have are skinny controllers that basically call on to the business layer for logic and data and then populate a local ViewModel to pass to the view.
I do unit test the business layer but I wonder if testing these skinny controllers still make sense or its really not necessary unless you have a fat controller with a lot of logic in it.
Please let me know your thoughts.
Thanks.
Kabosucash
is working on a reply...