示例#1
0
        protected TestFixture(string solutionRelativeTargetProjectParentDir)
        {
            var startupAssembly = typeof(TStartup).GetTypeInfo().Assembly;

            var builder = new WebHostBuilder()
                          .UseStartup(typeof(TStartup))
                          .ConfigureServices(InitializeServices)
                          .ConfigureAppConfiguration((hostContext, config) =>
            {
                config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
                config.AddJsonFile("customSettings.json", optional: true, reloadOnChange: true);
                config.AddJsonFile("patreonTokens.json", optional: true, reloadOnChange: true);
            });

            server             = new TestServer(builder);
            Client             = server.CreateClient();
            Client.BaseAddress = new Uri("http://localhost");

            if (File.Exists(Database.Path))
            {
                File.Delete(Database.Path);
            }

            Database = new Database(Database.Path);

            NLogLogger.ConfigureLogger();
            LogManager.Init(new NLogLogProvider());
        }