2
votes

I am using Hybrid caching in StructureMap, however during my unit tests I want to be able to clear the cache of StructureMap so that the code will construct new objects rather than taking them from the cache.

I see no method what so ever to clear the caches objects from StructureMap. Even when I re-Initialize the configuration, it still returns me the initial objects.

Has anyone got a work around for this? I would have thought ResetDefaults would solve this, but it doesnt!

1
Why are your unit tests dependant on the caching in StructureMap? Are you actually doing integration tests? Unit tests should not be dependant of any sort of SM configuration if they are truly testing just one class/unit. - Pete

1 Answers

3
votes

Have you tried

void IContainer::EjectAllInstancesOf<T>()