Thursday, May 31, 2012
by
Just* Team
|
Go comment!
In Doing Your First Mock, Mehfuz Hossain explained why you should use mocking to improve your unit tests and then used a real world example to demonstrate this technique. In this post, I will take you down a different path using other forms of stand-ins.
I will cover three types of objects used to improve unit testing:
These objects will be demonstrated using a SecurityHandler class which has been designed to allow injection of an interface in the constructor.
public class SecurityHandler
{
private readonly ILoginService _service;
public int UserID { get; internal set; }
public SecurityHandler(ILoginService service)
{
_service = service;
}
public bool LoginUser(string userName, string password)
{
return (UserID =...