Reputation: 27803
I have the following code in my application:
public class DirectoryCrawler
{
private IPathWrap _path;
private IDirectoryWrap _directory;
private ITrackedFileStore _trackedFileStore;
private IFileWrap _file;
public DirectoryCrawler(IPathWrap path, ITrackedFileStore trackedFileStore, IDirectoryWrap directory, IFileWrap file)
{
_path = path;
_trackedFileStore = trackedFileStore;
_directory = directory;
_file = file;
}
public void CheckDirectoryContents(string baseDirectory)
{
var trackedFiles = _trackedFileStore.GetTrackedFilesInPath(baseDirectory);
}
}
I'm unit testing it via:
[TestClass]
public class DirectoryCrawlerTests
{
private MockingContainer<DirectoryCrawler> _mockContainer;
[TestInitialize]
public void Setup()
{
_mockContainer = new MockingContainer<DirectoryCrawler>();
}
[TestMethod]
public void Requests_Tracked_Files_In_Path()
{
var instance = _mockContainer.Instance;
instance.CheckDirectoryContents("C:\\Test");
_mockContainer.Assert<ITrackedFileStore>(x => x.GetTrackedFilesInPath(Arg.IsAny<string>()), Occurs.Once());
}
}
However, the assert is failing claiming Result Message: Occurrence expectation failed. Expected exactly 1 call. Calls so far: 0
Why is JustMock not detecting the occurrence correctly? This is with the latest JustMock lite Nuget package (2014.1.1317.4)
Upvotes: 0
Views: 1603
Reputation: 65079
As stated in the comments, call verification is different when you use AutoMocking.
You must Arrange
the automocked dependency method to be called and specify it with MustBeCalled()
.
Upvotes: 0