-
-
Save emiaj/2499808 to your computer and use it in GitHub Desktop.
| var foo = new ObjectDef(typeof(Foo)); // you can also target a value instead of a type (new Foo()) | |
| foo.DependencyByType(typeof(IBar), typeof(Bar)); // by type | |
| foo.DependencyByValue(typeof(IBaz), new Baz()); // by value | |
| Services(x => | |
| { | |
| x.AddService(typeof(IFoo), foo); | |
| }); |
Well, it all ends up in the SM container, right?
You could add an activator (which is a one-time-only thing) that takes in the container and then you perform the assertion (I think it has an AssertGraphIsValid method or something like that).
Would that work in a test assembly? I mean, without the full bootstrapping. What it has is just:
var registry = new FubuRegistry();
ClassUnderTest.As<IFubuRegistryExtension>().Configure(registry);
_services = registry.BuildLightGraph().Services;
So, if I even add an IActivator, would it be.. activated?
Uhmm, in that case you need to walk through the services. I think it accepts a visitor so you can evaluate the plugin graph by yourself, but the rules dictating if is or if is not a valid plugin would be up to you.
If you also want to check that in your live app, you can also use an activator, just take in the BehaviorGraph which is IoC enabled in fubu and do the same check you do in your tests.
You probably are better asking this to JDM, he may give you a proper advice ;)
Ok, thanks for your help!
Thanks!
But I cannot figure how to actually check that all the dependency graph is valid for this type, i.e. no missing dependencies.