Skip to content

AssemblyAbstractions

LosManos edited this page Aug 2, 2021 · 1 revision

CompulsoryCow.AssemblyAbstractions

Does

Makes it possible to mock (not yet)all of System.Reflection.Assembly.

The problem solved

It is very hard to test Assembly related stuff as all constructors are static.
This class mimics original Assembly behaviour (it calls the original Assembly) but makes everything mockable and/or testable.

  • Some (not everything is implemented, yet) of System.Reflection.Assembly's instance methods and properties implemented as interface for making mocking easier.
  • The static constructors are moved to the class AssemblyFactory
  • When testing use the methods and properties in the partial class Assembly.Set to set explicit values.

Dependency injection

Inject AssemblyFactory and the calls should be, almost, as original dotnet code.

Code

Assembly

Clone this wiki locally