So I am trying to test a method call on another interface of my mock. Tried a few options and some tweaking here and there but it never registers the method as actually called. When I debug through the code/test the method is being called. The actual code is quite complex, so I created this abstract example of the problem. The class and method I want to test looks like the following:
public class ClassToTest
{
private readonly _domainRunner;
public ClassToTest(IDomainRunner domainRunner)
{
_domainRunner = domainRunner;
}
public void MethodToTest()
{
(_domainRunner as IRunner).RunAnotherTask();
}
}
The IDomainRunner and its relevant method I am trying to verify looks like this:
public class DomainRunner : IRunner, IDomainRunner
{
...
void IRunner.RunAnotherTask()
{
// irrelevant
}
}
And just for the complettness the basic test structure:
[TestClass]
public class DomainRunnerTests
{
[TestMethod]
public void TestRunSomeTask()
{
var domainRunnerMock = new Mock<IDomainRunner>();
var someClass = new ClassToTest(domainRunnerMock.Object):
// How to Assert that IRunner.RunAnotherTask was called?
}
}
I've tried to setup the Method RunAnotherTask
or to directly verify it, neither was successful. This code does not really seem untestable to me or i am that wrong?