The test-based design part should stimulate you depending on the injection. Often, when you find something difficult for unit testing, this is because you need to rethink your design.
-, , SomeObject. -. , , , , , , , , . :
public class ClassBeingTested
{
public ClassBeingTested(SomeObject so)
{
}
void MethodIAmTesting(SomeObject so)
{
}
}
, , , SomeObject. , , / .. , . , , , _someService SomeObject:
void EnsureSomeObjectPassedToService()
{
SomeObject so = new SomeObject()
_mainClass.MethodIAmTesting(so);
_someObject.AssertWasCalled(x => x.AnotherMethodCall(so));
}
! , .