You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request from one of our teams. Lamar is not nearly as flexible as StructureMap at runtime. This was a conscious decision on my part to improve performance and keep folks from shooting themselves in the foot and running to me for help when they did. The downside is that is that Lamar isn't that great for swapping in test services per test. You can use Injectable upfront, but that requires knowing which services will be swapped out ahead of time.
What if we had a mode where the container allowed for easier swapping at will, and reset all registrations back to the original registration with a single method call in a test fixture clean up? More investigation necessary. I'm thinking that in this mode Lamar uses QuickBuild() for everything so it's easier to swap things in and out.
The text was updated successfully, but these errors were encountered:
To piggyback, we have a common pattern in StructureMap:
Create "blueprint" root container
Create a nested container based on the root container
Use Configure to swap out a dependency for a mokc
Dispose the nested container
For .NET Core/5/6, we wind up using the WebApplicationFixture and OverrideServices stuff, but it forces us to rebuild the entire container every time. We do have well-known stubs injected into the container to swap out, like user sessions etc. But to do arbitrary mocking we have to rebuild the whole container.
Just to follow up, the strategy in the repo above doesn't work because it's trying to wrap the ServiceDescriptor instances in the service collection. However, Lamar populates those values with Lamar-specific things so the wrapped values are all wrong. Back to the drawing board.
// cc @kkorotky
Request from one of our teams. Lamar is not nearly as flexible as StructureMap at runtime. This was a conscious decision on my part to improve performance and keep folks from shooting themselves in the foot and running to me for help when they did. The downside is that is that Lamar isn't that great for swapping in test services per test. You can use
Injectable
upfront, but that requires knowing which services will be swapped out ahead of time.What if we had a mode where the container allowed for easier swapping at will, and reset all registrations back to the original registration with a single method call in a test fixture clean up? More investigation necessary. I'm thinking that in this mode Lamar uses QuickBuild() for everything so it's easier to swap things in and out.
The text was updated successfully, but these errors were encountered: