Let say you have a register action in your controller.
[HttpPost]
public ViewResult Register(string username, string email, string password, string repeatPassword)
This action will:
- Check and validate parameters
- Communicate and add a new data to
repository - Return a View.
Definitely need to unit test 1 and 3, but how about 2?
Is there any way to unit test 2 without having to implement the add method in the repository?
Thanks,
RWendi
Your test for #2 using Moq would be:
Moq’s Verify will behave like NUnit Assert and will fail the test if the expected method is not called.