I have to test IoC Service implemented in MyMobileApp.MyService.Module.
At the moment my unit test project MyMobileApp.MyService.Module.Tests has referenced on IoC Module MyMobileApp.MyService.Module
CFTestRunner is used for debugging and Visual Studio test runner can be also used to run test with output to GUI window(???)
IMHO this architecture has drawbacks:
- Services must be initialized manually in [TestInitialize]:
try
{
var module = new Module(); // Drawback: what if 2 services should be used?
module.AddServices();
}
catch (Exception) // Services must be added only once
{
// In TestInitialize
// ClassInitilaize method is not executed if unit test is running under CFTestRunner???
}
this.myService = RootWorkItem.Services.Get();
- To test another service implementation I should change reference and recompile test project
Therefore I have some improvements ideas:
Is it good to use testable version of ProfileCatalog to allow IoC container add testing services automatically? How can this ProfileCatalog correctly deployed on devcie/emulator?
Is it good to use inject services in test class (if it possible)?
Also where can I found sample code/project(s)/articles with good testing patterns - I mean testing IoC services