diff --git a/appveyor.test.ps1 b/appveyor.test.ps1 index 84c2ecff..0eefdcf7 100644 --- a/appveyor.test.ps1 +++ b/appveyor.test.ps1 @@ -38,7 +38,7 @@ function runUnitTest() { write-host "dotnet test test\UnitTest" -ForegroundColor Cyan - dotnet test test\UnitTest --filter "FullyQualifiedName!~MySql" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap*]*" /p:ExcludeByFile="..\..\src\admin\Bootstrap.Admin\Program.cs%2c..\..\src\admin\Bootstrap.Admin\Startup.cs" /p:CoverletOutput=..\..\ + dotnet test test\UnitTest /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*]*.MySql.*" /p:ExcludeByFile="..\..\src\admin\Bootstrap.Admin\Program.cs%2c..\..\src\admin\Bootstrap.Admin\Startup.cs%2c..\..\src\admin\Bootstrap.Admin\Extensions\SMSExtensions.cs%2c..\..\src\admin\Bootstrap.DataAccess\AutoDB.cs" /p:CoverletOutput=..\..\ } function coverallUnitTest() { diff --git a/src/admin/Bootstrap.DataAccess/DbManager.cs b/src/admin/Bootstrap.DataAccess/DbManager.cs index de5d18f9..5b482aa5 100644 --- a/src/admin/Bootstrap.DataAccess/DbManager.cs +++ b/src/admin/Bootstrap.DataAccess/DbManager.cs @@ -18,7 +18,7 @@ namespace Bootstrap.DataAccess /// /// /// - /// 是否记录日志 + /// 是否记录日志 /// public static IDatabase Create(string connectionName = null, bool keepAlive = false, bool enableLog = true) { diff --git a/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs index 5d7ce218..cc7feaf0 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/LogHelper.cs @@ -81,7 +81,7 @@ namespace Bootstrap.DataAccess while (_messageQueue.TryTake(out var log)) { logs.Add(log); - }; + } if (logs.Any()) { using (var db = DbManager.Create(enableLog: false)) diff --git a/test/UnitTest/Bootstrap.DataAccess/MongoDB/DBLogTest.cs b/test/UnitTest/Bootstrap.DataAccess/MongoDB/DBLogTest.cs new file mode 100644 index 00000000..47ff8061 --- /dev/null +++ b/test/UnitTest/Bootstrap.DataAccess/MongoDB/DBLogTest.cs @@ -0,0 +1,14 @@ +using Xunit; + +namespace Bootstrap.DataAccess.MongoDB +{ + [Collection("MongoContext")] + public class DBLogTest : SqlServer.DBLogTest + { + [Fact] + public override void Save_Ok() + { + Assert.True(new DBLog().Save(null)); + } + } +} diff --git a/test/UnitTest/Bootstrap.DataAccess/MySql/DBLogTest.cs b/test/UnitTest/Bootstrap.DataAccess/MySql/DBLogTest.cs new file mode 100644 index 00000000..3692ecf8 --- /dev/null +++ b/test/UnitTest/Bootstrap.DataAccess/MySql/DBLogTest.cs @@ -0,0 +1,10 @@ +using Xunit; + +namespace Bootstrap.DataAccess.MySql +{ + [Collection("MySqlContext")] + public class DBLogTest : SqlServer.DBLogTest + { + + } +} diff --git a/test/UnitTest/Bootstrap.DataAccess/SQLServer/DBLogTest.cs b/test/UnitTest/Bootstrap.DataAccess/SQLServer/DBLogTest.cs new file mode 100644 index 00000000..9c2bf32a --- /dev/null +++ b/test/UnitTest/Bootstrap.DataAccess/SQLServer/DBLogTest.cs @@ -0,0 +1,28 @@ +using System; +using Xunit; + +namespace Bootstrap.DataAccess.SqlServer +{ + [Collection("SQLServerContext")] + public class DBLogTest + { + [Fact] + public virtual void Save_Ok() + { + var log = new DBLog() + { + Id = "", + LogTime = DateTime.Now, + SQL = "UnitTest", + UserName = "UniTest" + }; + Assert.True(log.Save(log)); + } + + [Fact] + public void Save_Exception() + { + Assert.Throws(() => new DBLog().Save(null)); + } + } +} diff --git a/test/UnitTest/Bootstrap.DataAccess/SQLite/DBLogTest.cs b/test/UnitTest/Bootstrap.DataAccess/SQLite/DBLogTest.cs new file mode 100644 index 00000000..40ded307 --- /dev/null +++ b/test/UnitTest/Bootstrap.DataAccess/SQLite/DBLogTest.cs @@ -0,0 +1,10 @@ +using Xunit; + +namespace Bootstrap.DataAccess.SQLite +{ + [Collection("SQLiteContext")] + public class DBLogTest : SqlServer.DBLogTest + { + + } +}