Esempio n. 1
0
    public static Task <int> Main(string[] args)
    {
        ArgumentNullException.ThrowIfNull(args);

        args = SetProjectPathFromDotArgumentIfNeeded(args);
        args = SetHelpArgumentIfNeeded(args);

        var configuration = new ConfigurationBuilder()
                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
                            .Build();

        var consoleLoggerConfiguration = new ConsoleLoggerConfiguration();

        configuration.GetRequiredSection("ConsoleLogger").Bind(consoleLoggerConfiguration);

        ProgramCsHelper.SetMinimumLogLevelIfNeeded(args, consoleLoggerConfiguration);

        var serviceCollection = ServiceCollectionFactory.Create(consoleLoggerConfiguration);

        var app = CommandAppFactory.CreateWithRootCommand <RootCommand>(serviceCollection);

        app.ConfigureCommands();

        return(app.RunAsync(args));
    }
    public DbContextTestFixture(
        IServiceCollection serviceCollection     = null,
        IDependencyRetriever dependencyRetriever = null,
        IConstructorFilter constructorFilter     = null,
        ITargetFactory <T> targetFactory         = null)
    {
        var services = ServiceCollectionFactory.Create(serviceCollection ?? new ServiceCollection())
                       .AddDatabaseTestingUtilities <TContext>()
                       .BuildServiceProvider();

        this.DependencyRetriever = dependencyRetriever ?? services.GetService <IDependencyRetriever>();
        this.ConstructorFilter   = constructorFilter ?? services.GetService <IConstructorFilter>();
        this.TargetFactory       = targetFactory ?? new TargetFactory <T>(this.ConstructorFilter);
        this.Setup();
    }