The first DI example (shown below) doesn't agree with the text above it that references a private constructor.
public class DuplicateAccountBlocker
{
@testVisible private final AccountsSelector selector;
public DuplicateAccountBlocker()
{
this.selector = new AccountsSelector();
}
public DuplicateAccountBlocker(AccountSelector mockSelector)
{
this.selector = mockSelector;
}
//...
I think you meant the example to look like:
public class DuplicateAccountBlocker
{
private final AccountsSelector selector;
public DuplicateAccountBlocker()
{
this.selector = new AccountsSelector();
}
@TestVisible private DuplicateAccountBlocker(AccountSelector mockSelector)
{
this.selector = mockSelector;
}
//...
The first DI example (shown below) doesn't agree with the text above it that references a private constructor.
I think you meant the example to look like: