I had to write a test where I need to inject a configuration dependency through IOptions<>
. So far I had been using Autofac in my tests, so I wouldn’t go through all the trouble to get IOptions<>
working inside Autofac (especially when Microsoft DI offers the convenient AddOptions<>
and Configure<>
methods).
Luckily it is not that hard to bring the 2 DI containers together. Here is the code I used inside my tests: