i am a structure map begginer.
i wanna now whats the best practice of work with real configuration on regular application running, and have the ability to override stuff under test environment.
i tried to work with the inject method on a singletone, and it worked only once.
anyway, i'm not sure i'm working as i should with SM, so here is what i'm doing
for each dll in my app i created a class that inherits Regisry, in Main, first i tried call the scan and LookForRegistries
public ViewsRegistry()
{
Scan(Scanning);
//Profile("exe",x=>x.For<Application>().Use(x=>x.<>()))
}
private void Scanning(IAssemblyScanner assemblyScanner)
{
// I'm telling StructureMap to sweep a folder called "Extensions" directly
// underneath the application root folder for any assemblies found in that folder
assemblyScanner.AssembliesFromApplicationBaseDirectory(Filter);
// I also direct StructureMap to add any Registries that it finds in these
// assemblies. I'm assuming that all the StructureMap directives are
// contained in Registry classes -- and this is the recommended approach
assemblyScanner.LookForRegistries();
}
private bool Filter(Assembly obj)
{
return obj.FullName.StartsWith("MyPrefix");
}
it didn't work and i dont know why... so this is my first question.
so i decided to add the registries by my self for now.. and my application is running and everything is o.k.
when i got to my unit tests, i tried to load all regular registries and to inject stuff in order to override stuff in the application registries, and put stubs instead of real stuff.
is it the best practice or there r better ways?? i thought about working with profiles but i dont know how to configure singletones in profile.