Does Autofac have an equivalent to StructureMap's AssertConfigurationIsValid method? Or does configuration validation occur when creating the container?
I believe the AssertConfigurationIsValid method checks that the container can create all the configured services. Obviously it can't pick up more subtle configuration mistakes - related to scope, for instance - but it would be nice to know that we are doing as much as we can to prevent issues that could crop up at runtime.
I don't think Autofac have validation, and an exception is thrown at runtime if a service cannot be resolved. It would probably be useful but I always tend to write unit tests that validates that my container, or rather my modules, contain those services I expect it to have. Unit testing more than makes up for the lack of container validation.
These tests usually follow the pattern of
container.IsRegistered
container.Resolve
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With