Description
Mocking a hierarchy with a large depth doesn't build.
Expected Behavior
Application to compile.
Actual Behavior
Application does not compile.
Steps to Reproduce
public interface IDepth1
{
IDepth2 Inner { get; }
}
public interface IDepth2
{
IDepth3 Inner { get; }
}
public interface IDepth3
{
IDepth4 Inner { get; }
}
public interface IDepth4
{
IDepth5 Inner { get; }
}
public interface IDepth5
{
}
public class Tester
{
[Test]
public async Task LargeHierarchy()
{
var mock = IDepth1.Mock();
// If the mock type is generated then the build works
// var mock5 = IDepth5.Mock();
}
}
TUnit Version
1.56.0
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
TUnit.Mocks.SourceGenerator\TUnit.Mocks.SourceGenerator.MockGenerator\IDepth4_MockImplFactory.g.cs(19,156): error CS0400: The type or namespace name 'IDepth5MockFactory' could not be found in the global namespace (are you missing an assembly reference?)
Additional Context
I didn't debug to confirm, but this might be from MockTypeDiscovery having a max depth.
I think the design decision to not create mock types too far down the hierarchy is reasonable. I know I don't currently have a use case that requires it. The properties won't actually be used past a certain depth.
The problem is that it breaks the ability to mock the top level interface.
IDE-Specific Issue?
Description
Mocking a hierarchy with a large depth doesn't build.
Expected Behavior
Application to compile.
Actual Behavior
Application does not compile.
Steps to Reproduce
TUnit Version
1.56.0
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
I didn't debug to confirm, but this might be from
MockTypeDiscoveryhaving a max depth.I think the design decision to not create mock types too far down the hierarchy is reasonable. I know I don't currently have a use case that requires it. The properties won't actually be used past a certain depth.
The problem is that it breaks the ability to mock the top level interface.
IDE-Specific Issue?
dotnet testordotnet run, not just in my IDE