As I do not share the opinion that testing of private methods is an anti-pattern (to me, it is essential to implement complete button-up tests), I tried to implement a private accessor based on my post Home-made Private Accessor for Visual Studio 2012+ for a .NET Core project.
To my surprise, the required classesPrivateObject
and PrivateType
are not part of the .NET Core test framework. You can find an issue on that opened on GitHub: https://github.com/Microsoft/testfx/issues/366.
The not-so-good news on this is, that Microsoft decided not to take this feature back into the .NET Core test framework. The good news is, that the source of the required classes PrivateObject
and PrivateType
is published on GitHub.
You can either download a .zip containing one file with both classes from here: https://github.com/microsoft/testfx/files/4132970/PrivateObjectPrivateType.zip (I suggest to split this file into two, following one of my preferred development guidelines ‘one-type-per-file’). Or you can download them from the Microsoft TestFramework https://github.com/microsoft/testfx/tree/664ac7c2ac9dbfbee9d2a0ef560cfd72449dfe34/src/TestFramework/Extension.Desktop.
publicize.exe is still available when installing VS 2019, but I assume it will not generate the desired types for .NET Core assemblies, as the required base classes are missing (didn’t tested it; see Use Publicize.exe to Create Private Accessors for Visual Studio 2012+).