From 75e9eac8e2dd49fa62efd89b0d328eadc8a2968f Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 15 May 2019 11:08:31 +0800 Subject: [PATCH] =?UTF-8?q?test(build):=20=E5=A2=9E=E5=8A=A0Logging?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UnitTest/BAWebHost.cs | 12 ++++++++---- UnitTest/TestHelper.cs | 2 -- UnitTest/appsettings.json | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/UnitTest/BAWebHost.cs b/UnitTest/BAWebHost.cs index bb12dc1f..d23a37cc 100644 --- a/UnitTest/BAWebHost.cs +++ b/UnitTest/BAWebHost.cs @@ -68,9 +68,6 @@ namespace Bootstrap.Admin new KeyValuePair("DB:2:Enabled", "false"), new KeyValuePair("DB:3:Enabled", "false") })); - if (!string.IsNullOrEmpty(TestHelper.MongoDBName)) builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair[] { - new KeyValuePair("MongoDB", TestHelper.MongoDBName) - })); } } @@ -128,13 +125,20 @@ namespace Bootstrap.Admin TestHelper.SQLServerConnectionString = con.GetConnectionString("sqlserver-app"); TestHelper.MySqlConnectionString = con.GetConnectionString("mysql-app"); TestHelper.NpgSqlConnectionString = con.GetConnectionString("npgsql-app"); + builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair[] { + new KeyValuePair("Logging:LogLevel:Default", "Error"), + new KeyValuePair("Logging:LogLevel:System", "Error"), + new KeyValuePair("Logging:LogLevel:Microsoft", "Error") + })); } else { TestHelper.SQLServerConnectionString = con.GetConnectionString("sqlserver"); TestHelper.MySqlConnectionString = con.GetConnectionString("mysql"); TestHelper.NpgSqlConnectionString = con.GetConnectionString("npgsql"); - TestHelper.MongoDBName = con.GetValue("MongoDB", "UnitTest"); + builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair[] { + new KeyValuePair("MongoDB", con.GetValue("MongoDB", "UnitTest")) + })); } TestHelper.SQLiteConnectionString = con.GetConnectionString("sqlite"); TestHelper.ConfigureWebHost(builder); diff --git a/UnitTest/TestHelper.cs b/UnitTest/TestHelper.cs index e1c3814a..3ca8a431 100644 --- a/UnitTest/TestHelper.cs +++ b/UnitTest/TestHelper.cs @@ -17,8 +17,6 @@ namespace UnitTest public static string NpgSqlConnectionString { get; set; } - public static string MongoDBName { get; set; } - /// /// 获得当前工程解决方案目录 /// diff --git a/UnitTest/appsettings.json b/UnitTest/appsettings.json index cb258d09..6c6c04a0 100644 --- a/UnitTest/appsettings.json +++ b/UnitTest/appsettings.json @@ -1,4 +1,9 @@ { + "Logging": { + "LogLevel": { + "Default": "Debug" + } + }, "MongoDB": "UnitTest", "ConnectionStrings": { "sqlite": "Data Source=UnitTest.db;",