コード例 #1
0
        public BaseDITest()
        {
            _projetctPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;

            var configBuilder = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.Development.json", optional: false, reloadOnChange: true)
                                .AddEnvironmentVariables();

            this._configuration = configBuilder.Build();

            var services = new ServiceCollection();

            services.AddSingleton(this._configuration);
            services.AddOptions();
            services.AddMemoryCache();

            InfrastructureEnvironment.ContentRoot = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location.Substring(0, Assembly.GetEntryAssembly().Location.IndexOf("bin\\")));

            InfrastructureDependencyInjectionHelper.Inject(services, this._configuration);
            MLServicesDependencyInjectionHelper.Inject(services, this._configuration);
            CreditAnalysisServicesDependencyInjectionHelper.Inject(services, this._configuration);

            this._serviceProvider = services.BuildServiceProvider();

            Log.Logger.Information("CreditAnalysis.Test Iniciado...");
        }
コード例 #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews().AddRazorRuntimeCompilation();

            services.AddOptions();
            services.AddMemoryCache();

            try
            {
                InfrastructureEnvironment.ContentRoot = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location.Substring(0, Assembly.GetEntryAssembly().Location.IndexOf("bin\\")));
            }
            catch (System.Exception)
            {
                InfrastructureEnvironment.ContentRoot = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            }


            InfrastructureDependencyInjectionHelper.Inject(services, this.Configuration);
            MLServicesDependencyInjectionHelper.Inject(services, this.Configuration);
            CreditAnalysisServicesDependencyInjectionHelper.Inject(services, this.Configuration);

            Log.Logger.Information("CreditAnalysis.Test Iniciado...");
        }