unit testing - How to test whether my factories are properly bound? -


using ninject, have following , wish test using fluentassertions:

[test] public void interfacesendingwithfactoryshouldbeboundasfactories() {     // given     ikernel kernel = new standardkernel();     kernel.bind(services => services         .from(appdomain.currentdomain             .getassemblies()             .where(a => !a.fullname.contains("tests")))         .selectallinterfaces()         .endingwith("factory")         .bindtofactory()     );      // when     var factory = kernel.get<icustomermanagementpresenterfactory>();      //     factory.should().notbenull(); } 

is there ways test whether factories bound properly?

i wrote extension package fluent assertions test ninject bindings. using test rewritten this:

[test] public void interfacesendingwithfactoryshouldbeboundasfactories() {     // given     ikernel kernel = new standardkernel();     kernel.bind(services => services         .from(appdomain.currentdomain             .getassemblies()             .where(a => !a.fullname.contains("tests")))         .selectallinterfaces()         .endingwith("factory")         .bindtofactory()     );      // when       //     kernel.should().resolve<icustomermanagementpresenterfactory>().withsingleinstance() } 

as suggested @will marcouiller, extract code bootstrap kernel it's own class can invoked in app's composition root , in unit tests.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -