JustMock makes isolating your unit test from a dependency to a local function an easy task, allowing you to mock it. In most cases, mocking local functions is similar to mocking class methods.
Part of the fastest, most flexible and complete mocking tool for crafting unit tests.
Our award-winning support team is available to assist you with any issues.
A local function is a private function whose scope is limited to the scope of the function in which it is created. The local function can be called only within the container member and with this—a dependency to the container member.
JustMock makes isolating your unit test from the local function an easy task, allowing you to mock it. In most cases, mocking local functions is similar to mocking class methods.
classFoo
{
publicintGetResult()
{
return100 + GetLocal();
intGetLocal ()
{
return42;
}
}
}
...
[TestClass]
publicclassMockLocalFunctions
{
[TestMethod]
publicvoidBasicUsage()
{
//Arrange
var sut = Mock.Create<Foo>(Behavior.CallOriginal);