Mocking context-Procedures
See original GitHub issueWe have setup database-first with exports for Stored Procedures. This creates an export class that contains an method Procedures
in our partial context.
Currently we’re trying to mock a Stored Procedure in our unit tests, but we’re failing because the Procedures
property is neither part of an interface, nor is the property marked as virtual.
We would like to propose one line of code change in the generation of the Procedures
property here: https://github.com/ErikEJ/EFCorePowerTools/blob/f35ad68c31cc2a1c1dd5fdd38c08c9a6bd6966a0/src/GUI/RevEng.Core/Procedures/SqlServerStoredProcedureScaffolder.cs#L96
- _sb.AppendLine($"public {procedureScaffolderOptions.ContextName}Procedures Procedures");
+ _sb.AppendLine($"public virtual {procedureScaffolderOptions.ContextName}Procedures Procedures");
Just like all DbSets
are virtual, this property needs to be virtual too.
Surprisingly the generated methods in the context-procedures class are all virtual.
We also tried to work-around this issue with Handlebars, but it looks like there are no templates available for Stored Procedures. Separate issue?!
Steps to reproduce
- Database-first
- Enable and export Stored Procedures
- Try to mock (Moq) an Stored Procedure
Further technical details
EF Core Power Tools version: 2.5.758.
Database engine: SQL Server.
Visual Studio version: Visual Studio Professional 2019 16.11.3.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:16 (11 by maintainers)
Top GitHub Comments
Finally had time to officially test the extension (version 2.5.1041) and the interface changes are working great 👍
fixed in latest daily build