I am using .CallBase() in order to execute the real code behind the mock for the .Export() method from within the TsExporter class.
On the other side, the .RetrieveTranslations() is executing the real code too, and not returning the mocked value as "I told it to do it".
Here is the code:
[TestFixture]
public class TestClass
{
private Mock<ITsExporter> _tsExporter;
[SetUp]
public void SetUp()
{
_tsExporter = new Mock<TsExporter>().As<ITsExporter>();
//This is calling the real code which is good
_tsExporter.Setup(x => x.Export(It.IsAny<TsFileModel>(), It.IsAny<string>()))
.CallBase();
//but this is calling the real code too, and I was expecting not to
//call it and return the mock instead...
_tsExporter.Setup(x => x.RetrieveTranslations(It.IsAny<DataTable>(),
It.IsAny<string>(), It.IsAny<string>()))
.Returns(new DataTable());
}
[Test]
public void Test()
{
_tsExporter.Object.Export(new TsFileModel(), "");
}
}
What am I missing ?
Thank you !