public void ConfigureServices_is_noop_when_not_found() { var startup = new StartupInvoker( typeof(StartupInvokerTest).GetTypeInfo().Assembly, environment: "Unknown"); var services = startup.ConfigureServices(); Assert.NotNull(services); }
public void ConfigureServices_invokes_method_with_alternative_signature() { var startup = new StartupInvoker( typeof(StartupInvokerTest).GetTypeInfo().Assembly, "Alternative"); var services = startup.ConfigureServices(); var service = services.GetRequiredService <TestService>(); Assert.Equal("Alternative", service.Value); }
public void ConfigureServices_invokes_static_methods() { var startup = new StartupInvoker( typeof(StartupInvokerTest).GetTypeInfo().Assembly, "Static"); var services = startup.ConfigureServices(); var service = services.GetRequiredService <TestService>(); Assert.Equal("Static", service.Value); }
public void ConfigureServices_uses_Development_environment_when_unspecified() { var startup = new StartupInvoker( typeof(StartupInvokerTest).GetTypeInfo().Assembly, environment: null); var services = startup.ConfigureServices(); var service = services.GetRequiredService <TestService>(); Assert.Equal("Development", service.Value); }
public DbContextOperations( [NotNull] IOperationReporter reporter, [NotNull] Assembly assembly, [NotNull] Assembly startupAssembly) { Check.NotNull(reporter, nameof(reporter)); Check.NotNull(assembly, nameof(assembly)); Check.NotNull(startupAssembly, nameof(startupAssembly)); _reporter = reporter; _assembly = assembly; _startupAssembly = startupAssembly; var startup = new StartupInvoker(reporter, startupAssembly); _runtimeServices = startup.ConfigureServices(); }
public DbContextOperations([NotNull] ILoggerProvider loggerProvider, [NotNull] Assembly assembly, [NotNull] Assembly startupAssembly, [CanBeNull] string environment, [NotNull] string contentRootPath) { Check.NotNull(loggerProvider, nameof(loggerProvider)); Check.NotNull(assembly, nameof(assembly)); Check.NotNull(startupAssembly, nameof(startupAssembly)); Check.NotEmpty(contentRootPath, nameof(contentRootPath)); _loggerProvider = loggerProvider; _assembly = assembly; _startupAssembly = startupAssembly; _environment = environment; _contentRootPath = contentRootPath; _logger = new LazyRef<ILogger>(() => _loggerProvider.CreateCommandsLogger()); var startup = new StartupInvoker(_logger, startupAssembly, environment, contentRootPath); _runtimeServices = startup.ConfigureServices(); }
public DbContextOperations( [NotNull] IOperationReporter reporter, [NotNull] Assembly assembly, [NotNull] Assembly startupAssembly, [CanBeNull] string environment, [NotNull] string contentRootPath) { Check.NotNull(reporter, nameof(reporter)); Check.NotNull(assembly, nameof(assembly)); Check.NotNull(startupAssembly, nameof(startupAssembly)); Check.NotEmpty(contentRootPath, nameof(contentRootPath)); _reporter = reporter; _assembly = assembly; _startupAssembly = startupAssembly; _environment = environment; _contentRootPath = contentRootPath; var startup = new StartupInvoker(reporter, startupAssembly, environment, contentRootPath); _runtimeServices = startup.ConfigureServices(); }
public void Invoke_warns_on_error() { var log = new List<Tuple<LogLevel, string>>(); var startup = new StartupInvoker( new LazyRef<ILogger>(() => new ListLoggerFactory(log).CreateLogger("Test")), MockAssembly.Create(typeof(BadStartup)), /*environment:*/ null, "Irrelevant"); var services = startup.ConfigureServices(); Assert.NotNull(services); Assert.Equal( DesignCoreStrings.InvokeStartupMethodFailed( "ConfigureServices", typeof(BadStartup).DisplayName(), "Something went wrong."), log[0].Item2); }
public void ConfigureServices_injects_services() { var assembly = MockAssembly.Create(typeof(StartupInjected)); var startup = new StartupInvoker( new LazyRef<ILogger>(() => new LoggerFactory().CreateLogger("Test")), assembly, "Injected", @"C:\The\Right\Path"); var services = startup.ConfigureServices(); var service = services.GetRequiredService<TestService>(); Assert.Equal("Injected", service.Value); }