mattwhitfield/Unitverse

Set up mock dependency void calls as verifiable

Closed this issue ยท 2 comments

Example class:

public class JaffaCake
{
    private IRepository _repo;
    public JaffaCake(IRepository repo)
    {
        _repo = repo;
    }

    public void Nom()
    {
        if (!_repo.DoWeHaveAnyJaffaCakesLeft())
        {        
            throw new TableFlipException();
        }
        _repo.RecordJaffaCakeEaten();
    }
}

Scenario:
When using UseMockBehaviourStrict=True in the Unitverse settings, and Moq, the generated test will set up the DoWeHaveAnyJaffaCakesLeft call to return true/false. But it doesn't set up the RecordJaffaCakeEaten() void to be verifiable, so when enabling Strict mode for mocks, there's an extra step to manually add this line:

_repo.Setup(mock => mock.RecordJaffaCakeEaten()).Verifiable();

Would be great if that could be code gen'd

Let me know if that doesn't work for you.

Also, definitely counting this one as feature not bug ๐Ÿ˜‚

Cheers, will do ๐Ÿ‘

image

๐Ÿ˜