I’m mocking the following interface:
public IVirtualFile
{
string Contents { get; set; }
// ...
void SaveToDisk();
// ...
}
With this:
[TestFixture]
public TestVirtualFile
{
[OneTimeSetUp]
public void CreateMocks()
{
// ...
Mock<IVirtualFile> mockVirtualFile = new Mock<IVirtualFile>();
mockVirtualFile.Setup(vf => vf.SaveToDisk()).Callback(() => CheckSavedData());
// ...
}
private void CheckSavedData()
{
// ...
}
}
The thing is, I want CheckSavedData()
to use Assert
to test the Contents
property of my mock object.
So how can I pass said mock object to the method? Or should I make mockVirtualFile
a property of TestVirtualFile
and use it in CheckSavedData()
?