Last active
May 10, 2018 06:01
-
-
Save memark/e7947dfa0270c8cca2e34db3e60a2fa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void RegisterBusinessLogicStubs(ContainerBuilder containerBuilder) | |
{ | |
var tempContainerBuilder = new ContainerBuilder(); | |
var module = BusinessLogicAutofacModule.CreateWithoutDatabaseDefaults(default, default, default, default, default, default, default, default); | |
containerBuilder.RegisterModule(module); | |
var tempContainer = tempContainerBuilder.Build(); | |
var interfaceToStubList = tempContainer.ComponentRegistry.Registrations | |
.SelectMany(x => x.Services) | |
.OfType<IServiceWithType>() | |
.Select(x => x.ServiceType) | |
.Where(x => x.IsInterface); | |
var stubList = interfaceToStubList.Select(x => Substitute.For(new[] { x }, new object[] { })); | |
foreach (var s in stubList) | |
containerBuilder.RegisterInstance(s).AsImplementedInterfaces(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment