Unitverse
Unitverse copied to clipboard
Support Primary Constructors
When generating tests, the code for instantiating the test class is not generated correctly if the class has a primary constructor. The constructor parameters are missing.
Example:
public class RequestHandler(IOptions<CommonOptions> options) { private readonly CommonOptions _options = options.Value!; }
Generated test class:
`public class RequestHandlerTests { private readonly RequestHandler testClass;
public RequestHandlerTests ()
{
_testClass = new CustomerAccountEventsRequestHandler( the construtor parameter is missing here );
}
}`
Expected test class:
`public class RequestHandlerTests { private readonly CustomerAccountEventsRequestHandler _testClass; private readonly IOptions<CommonOptions> _options;
public RequestHandlerTests ()
{
_options = Substitute.For<IOptions< CommonOptions >>();
_testClass = new CustomerAccountEventsRequestHandler(_options);
}
}`