public void Setup() { var container = new ServiceCollection(); container.AddScoped <ITestService, TestService>(); DependencyInjection = new MicrosoftDependencyInjection(container); DependencyInjection.Build(); }
public void DependencyInjection_can_register_open_generic() { //arrange var container = new ServiceCollection(); var di = new MicrosoftDependencyInjection(container); di.RegisterSchedules(typeof(TestSchedule).Assembly); di = new MicrosoftDependencyInjection(container); di.Build(); //act var resolved = di.GetScope().GetInstance <IProcessSchedule <TestSchedule> >(); //assert resolved.Should().NotBeNull(); }
public void Dependency_injection_can_resolve_service_from_RegisterOpenGenericType() { var container = new ServiceCollection(); container.AddScoped <ITestService, TestService>(); container.AddSingleton <ICountable>(Mock.Of <ICountable>()); MicrosoftDependencyInjectionExtensions.RegisterOpenGenericType(container, typeof(TestCommandHandler), typeof(IProcessCommand <,>)); var dependencyInjection = new MicrosoftDependencyInjection(container); dependencyInjection.Build(); var testHandler = dependencyInjection.GetScope().GetInstance <IProcessMessage <TestMessage> >(typeof(IProcessCommand <TestMessage, TestMessageSettings>)); testHandler.Should().NotBeNull(); }