c# - How to test .net project with Ninject in proper way -
we have project separated bussiness layer. it's lots of services (classes) in separated project in solution. use ninject manage dependancies. classes in bussiness layes project internal, , communicates «another world» through interfaces. if create new project contain test wont see internal classes (but yeah can hack , declare internal public in asseblyinfo).
what need know what's neccessary test:
we can create test envirement of everything, , test through produced interfaces (there no «clear» dal, using linq2sql, possible mocked) way looks goods, because know nothing internal bislayer structure , test «contract» functionality. bad side system has lots of options, settings , bindings , seems impossible or pretty hard check possible variants of it
we can place tests in same project or set attribute make internal being seen public, we'd able test internal classes. because can test everything, hard control bindings, cos it'd nice ninject it, , override bindings need in concret test. not clear how test classes implementing same interface (and doing similar things). have few implementations of cache each impl-tion keeps data in different places (mssql, key-value db, asp cache, etc), tests each implementation same
as need have access classes in order test. so, make internals exposed outside trough interfaces accessible outside.
write tests against behaviour exposed outside, "another world" call it. write more generic test cases first , go details needed. ongoing process development/change of actual functionality you'll able decide how many fine grained scenarios need.
also take @ ninject mocking kernel extension https://github.com/ninject/ninject.mockingkernel
Comments
Post a Comment