frup42 / apex-mocks-sfdx

Demonstrates usage of ApexMocks in SFDX
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

DI example doesn't agree with explanatory text #3

Open cropredyHelix opened 5 years ago

cropredyHelix commented 5 years ago

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;
    }

    //...