SimonG96 / LightweightIocContainer

A lightweight IOC Container that is powerful enough to do all the things you need it to do.
MIT License
4 stars 2 forks source link

Add validate method #44

Closed SimonG96 closed 2 years ago

SimonG96 commented 4 years ago

Add a Validate() method to the IIocContainer that can be called from a test and checks if all registered types in the given installers can be resolved.

theKBro commented 2 years ago

How to validate factories?

ValidateFactories().WithArgument<IABC>(new ABC()).WithArgument<IBCE>(new BCE());

or more specific?

SimonG96 commented 2 years ago

Not quite sure yet

theKBro commented 2 years ago

better:

container.AddFactoryValidation<ITestFactory>().WithArgument<string>("hi");
..
..
container.ValidateFactories()

throwing exception if not for all factories a validation is registered

theKBro commented 2 years ago

What about factories with multiple create methods?

SimonG96 commented 2 years ago

Validate everything by calling Validate() Special parameters can be added by calling AddParameter<TInterface, TParameter>(parameter)

SimonG96 commented 2 years ago

What about factories with multiple create methods?

Every create method is verified if it can successfully create it's type.

theKBro commented 2 years ago

Else only one exception is thrown for the first not working resolve? Could you instead throw an Aggregate exception for all not working registrations?

SimonG96 commented 2 years ago

Else only one exception is thrown for the first not working resolve? Could you instead throw an Aggregate exception for all not working registrations?

Done 🚀