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
Inspecting the Composition instance and stepping through the code during debugging shows that the test setup isn't overriding the original as I'd like. Is there an approach I should use?
Pure.DI is not a DI container, but a source code generator. All code is generated at compile time. It's the same with tests. In the example you will find integration tests, I guess your question is more related to them.
This example generates a test composition based on settings from the Lib library:
privatevoidSetup()=>DI.Setup(nameof(MyServiceTests))// Based on the Composition setup from the Lib namespace.DependsOn("Lib.Composition")// Overrides some instances using mocks.Bind<IOutput>().To(_ =>_output.Object).Bind<IInput>().To(_ =>_input.Object)// Exposing a test instance as the composition root .Root<IService>("Service");
In the test composition, some of the objects are replaced by Mocks. And the test object is defined as the root of the composition.
Activity
NikolayPianikov commentedon May 21, 2024
I've added sample tests in this repository.
Pure.DI is not a DI container, but a source code generator. All code is generated at compile time. It's the same with tests. In the example you will find integration tests, I guess your question is more related to them.
This example generates a test composition based on settings from the Lib library:
In the test composition, some of the objects are replaced by Mocks. And the test object is defined as the root of the composition.