Private Accessor for .NET Core Assemblies

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 …

Disable Entity Framework Code First Initialization Logic

When you use the Entity Framework Code First approach to build your database, EF’s default behavior is to verify if a database exists when the application runs the first time. In case it does not exist, EF creates it. There might exist some situations when there is no need to …

Use Publicize.exe to Create Private Accessors for Visual Studio 2012+

Preface Starting with Visual Studio 2012, private accessors cannot be created any more by the IDE. The post Home-made Private Accessor for Visual Studio 2012+ presents an approach on how to create private accessors using the class Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject. Axel Mayer noted in the MSDN forums post How to create private …

Home-made Private Accessor for Visual Studio 2012+

Why Home-made? Short answer: Starting with Visual Studio 2012, private accessors cannot be created any more by the IDE. It seems that this does not bother too many people. The ‘Bring Back Private Accessor’ suggestion on UserVoice has not found any supporters right now. Nevertheless, I still need access to …

Unit-Testing of Private Async Methods with Visual Studio

Description Given there is the need to unit-test a private async method. The class to be tested might look like this: public ClassWithPrivateAsyncMethod { // Some stuff private async Task PrivateMethodAsync ( string input ) { // Call some async framework method var result = await SomeFrameworkMethodAsync(input); // do something …

Limitations of Private Accessors and Generic Methods (JIT Compiler Encountered an Internal Limitation)

Private accessors are really helpful for extensive unit testing. But they do have their limitations. I wrote a generic protected method having a declaration like this: protected ReturnType MyMethod<T>(OneClass, DateTime, DateTime, Func<OtherClass, T>, out List<T>); Calling this method via an accessor in my unit test, I ran into an exception …