Suppose that my Foo
class has the following:
readonly IService service;
public Foo(IService service)
{
if (service == null)
throw new ArgumentNullException("service");
this.service = service;
}
public void Start()
{
service.DoStuff();
}
So far, I have one unit test for the constructor where I pass in null to verify that an ArgumentNullException
gets thrown. Do I need a second unit test for my constructor where I pass in a valid IService
and verify that this.service
gets set (which would require a public accessor)?
Or should I just rely on my unit test for the Start
method to test this code path?