-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
In a regular ASP.NET project, for example, you can set up your DI via Startup.cs:
services.AddSingleton<IServiceA, ServiceA>()
.AddSingleton<IServiceB, ServiceB>();and in the test project, you can do this to override the configured DI for the main project (see here):
builder.ConfigureTestServices(services => services.AddSingleton<IServiceA, MockServiceA>());Is there a way to do something similar with this library? I have tried the following:
Main project (has no knowledge of test project):
// Composition.cs
public partial class Composition;
// Startup.cs
DI.Setup("Namespace.Composition").Bind<IServiceA>().As(Lifetime.Singleton).To<ServiceA>().Root<IServiceA>();Test project (references main project):
// BaseTest.cs
DI.Setup("Namespace.Composition")
.Bind<IServiceA>().As(Lifetime.Singleton).To(_ => Mock.Of<IServiceA>).Root<IServiceA>();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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested