From 6434cea61c8b3804412f5657dc6e387014503ea1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 8 Oct 2019 19:38:17 +0800 Subject: [PATCH 1/6] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20Mobile=20?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 1 - .../Controllers/Api/LoginController.cs | 6 +- .../Extensions/SMSExtensions.cs | 3 +- test/UnitTest/BAWebHost.cs | 35 +++++++++++ .../Api/SQLServer/LoginTest.cs | 7 +-- .../Controllers/SQLServer/AccountTest.cs | 60 ++++++++++++++----- 6 files changed, 85 insertions(+), 27 deletions(-) diff --git a/src/admin/Bootstrap.Admin/Controllers/AccountController.cs b/src/admin/Bootstrap.Admin/Controllers/AccountController.cs index badd20d0..4e35fd22 100644 --- a/src/admin/Bootstrap.Admin/Controllers/AccountController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/AccountController.cs @@ -2,7 +2,6 @@ using Bootstrap.DataAccess; using Longbow.GiteeAuth; using Longbow.GitHubAuth; -using Longbow.Web; using Longbow.WeChatAuth; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies; diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/LoginController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/LoginController.cs index 4976e1bd..4be219ce 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/LoginController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/LoginController.cs @@ -52,11 +52,7 @@ namespace Bootstrap.Admin.Controllers.Api /// [AllowAnonymous] [HttpPut] - public async Task Put([FromServices]ISMSProvider provider, [FromQuery]string phone) - { - if (string.IsNullOrEmpty(phone)) return false; - return await provider.SendCodeAsync(phone); - } + public async Task Put([FromServices]ISMSProvider provider, [FromQuery]string phone) => string.IsNullOrEmpty(phone) ? false : await provider.SendCodeAsync(phone); /// /// 跨域握手协议 diff --git a/src/admin/Bootstrap.Admin/Extensions/SMSExtensions.cs b/src/admin/Bootstrap.Admin/Extensions/SMSExtensions.cs index 33b31aac..331dc57a 100644 --- a/src/admin/Bootstrap.Admin/Extensions/SMSExtensions.cs +++ b/src/admin/Bootstrap.Admin/Extensions/SMSExtensions.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -241,7 +240,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// 获得/设置 默认授权 App /// - public string App { get; set; } + public string App { get; set; } = "0"; /// /// 获得/设置 短信下发网关地址 diff --git a/test/UnitTest/BAWebHost.cs b/test/UnitTest/BAWebHost.cs index fafbc137..f8aa41c7 100644 --- a/test/UnitTest/BAWebHost.cs +++ b/test/UnitTest/BAWebHost.cs @@ -10,6 +10,8 @@ using System.Net; using System.Net.Http; using UnitTest; using Xunit; +using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; namespace Bootstrap.Admin { @@ -119,6 +121,39 @@ namespace Bootstrap.Admin builder.ConfigureAppConfiguration(app => app.AddJsonFile(TestHelper.RetrievePath($"UnitTest{Path.DirectorySeparatorChar}appsettings.appveyor.json"), false, true)); } TestHelper.ConfigureWebHost(builder); + + // 替换 SMS 服务 + builder.ConfigureServices(services => + { + services.AddTransient(); + }); + } + + + /// + /// 手机号登陆帮助类 + /// + class DefaultSMSProvider : ISMSProvider + { + /// + /// 获得 短信配置信息 + /// + public SMSOptions Option { get; protected set; } = new SMSOptions(); + + /// + /// 下发验证码方法 + /// + /// + /// + public Task SendCodeAsync(string phoneNumber) => Task.FromResult(true); + + /// + /// 验证验证码方法 + /// + /// 手机号 + /// 验证码 + /// + public bool Validate(string phone, string code) => code == "1234"; } } } diff --git a/test/UnitTest/Bootstrap.Admin/Api/SQLServer/LoginTest.cs b/test/UnitTest/Bootstrap.Admin/Api/SQLServer/LoginTest.cs index df7d7e2d..e8b6dbd8 100644 --- a/test/UnitTest/Bootstrap.Admin/Api/SQLServer/LoginTest.cs +++ b/test/UnitTest/Bootstrap.Admin/Api/SQLServer/LoginTest.cs @@ -39,10 +39,9 @@ namespace Bootstrap.Admin.Api.SqlServer var _token = await resq.Content.ReadAsStringAsync(); Assert.Equal("false", _token); - // UNDONE: 重构短信登陆后完善 - //resq = await Client.PutAsync("?phone=", new StringContent("")); - //_token = await resq.Content.ReadAsStringAsync(); - //Assert.Equal("true", _token); + resq = await Client.PutAsync("?phone=18910001000", new StringContent("")); + _token = await resq.Content.ReadAsStringAsync(); + Assert.Equal("true", _token); } [Fact] diff --git a/test/UnitTest/Bootstrap.Admin/Controllers/SQLServer/AccountTest.cs b/test/UnitTest/Bootstrap.Admin/Controllers/SQLServer/AccountTest.cs index 1ebe11f9..e682c273 100644 --- a/test/UnitTest/Bootstrap.Admin/Controllers/SQLServer/AccountTest.cs +++ b/test/UnitTest/Bootstrap.Admin/Controllers/SQLServer/AccountTest.cs @@ -1,10 +1,8 @@ using Bootstrap.DataAccess; using System; -using System.Collections.Concurrent; using System.Linq; using System.Net; using System.Net.Http; -using System.Reflection; using Xunit; namespace Bootstrap.Admin.Controllers.SqlServer @@ -123,22 +121,54 @@ namespace Bootstrap.Admin.Controllers.SqlServer } [Fact] - public void Mobile_Ok() + public async void Mobile_Ok() { - // UNDONE: Mobile 单元测试未完成 + using (var db = DbManager.Create()) db.Execute("delete from Users where UserName = @0", "18910001000"); + var client = Host.CreateClient(); + var r = await client.GetAsync("/Account/Login"); + var view = await r.Content.ReadAsStringAsync(); + var tokenTag = ""); + var antiToken = view.Substring(0, index); - // 反射设置 SMSHelper 内部验证码保证 Validate 方法返回真 - var validateCodeInstance = Activator.CreateInstance(Type.GetType("Bootstrap.DataAccess.SMSHelper+AutoExpireValidateCode, Bootstrap.DataAccess"), new object[] { "18910001000", "1234", TimeSpan.FromSeconds(10)}); - var _poolInstance = typeof(SMSHelper).GetField("_pool", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); - //_pool.AddOrUpdate(option.Phone, key => new AutoExpireValidateCode(option.Phone, result.Data, option.Expires), (key, v) => v.Reset(result.Data)); - //var addMethod = _poolInstance.GetType().GetMethod("AddOrUpdate"); - //addMethod.Invoke(_poolInstance, new object[] { "18910001000", validateCodeInstance, null }); + var content = new MultipartFormDataContent + { + { new StringContent("18910001000"), "phone" }, + { new StringContent("1234"), "code" }, + { new StringContent(antiToken), "__RequestVerificationToken" } + }; + var m = await client.PostAsync("/Account/Mobile", content); + Assert.True(m.IsSuccessStatusCode); + var payload = await r.Content.ReadAsStringAsync(); + Assert.Contains("登 录", payload); + } - //var client = Host.CreateClient(); - //var r = await client.GetAsync($"/Account/Mobile?phone=18910001000&code=1234"); - //Assert.True(r.IsSuccessStatusCode); - //var content = await r.Content.ReadAsStringAsync(); - //Assert.Contains("登 录", content); + [Fact] + public async void Mobile_Fail() + { + using (var db = DbManager.Create()) db.Execute("delete from Users where UserName = @0", "18910001000"); + + var client = Host.CreateClient(); + var r = await client.GetAsync("/Account/Login"); + var view = await r.Content.ReadAsStringAsync(); + var tokenTag = ""); + var antiToken = view.Substring(0, index); + + var content = new MultipartFormDataContent + { + { new StringContent("18910001000"), "phone" }, + { new StringContent("1000"), "code" }, + { new StringContent(antiToken), "__RequestVerificationToken" } + }; + var m = await client.PostAsync("/Account/Mobile?AppId=0", content); + Assert.True(m.IsSuccessStatusCode); + var payload = await r.Content.ReadAsStringAsync(); + Assert.Contains("登 录", payload); } } } From 39c0d4965c2844b1927c131a3f72a81cdc137b5d Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 8 Oct 2019 20:15:34 +0800 Subject: [PATCH 2/6] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20HttpHeaderOper?= =?UTF-8?q?ation=20=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appveyor.test.ps1 | 2 +- .../Extensions/HttpHeaderOperation.cs | 2 -- .../Api/HttpHeaderOperationTest.cs | 21 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 test/UnitTest/Bootstrap.Admin/Api/HttpHeaderOperationTest.cs diff --git a/appveyor.test.ps1 b/appveyor.test.ps1 index 4fa1c7b0..84c2ecff 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%2c..\..\src\admin\Bootstrap.Admin\HttpHeaderOperation.cs" /p:CoverletOutput=..\..\ + 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=..\..\ } function coverallUnitTest() { diff --git a/src/admin/Bootstrap.Admin/Extensions/HttpHeaderOperation.cs b/src/admin/Bootstrap.Admin/Extensions/HttpHeaderOperation.cs index 5c9fae1f..f479233d 100644 --- a/src/admin/Bootstrap.Admin/Extensions/HttpHeaderOperation.cs +++ b/src/admin/Bootstrap.Admin/Extensions/HttpHeaderOperation.cs @@ -17,8 +17,6 @@ namespace Bootstrap.Admin /// public void Apply(OpenApiOperation operation, OperationFilterContext context) { - if (operation.Parameters == null) operation.Parameters = new List(); - if (context.MethodInfo.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Length == 0) { operation.Parameters.Add(new OpenApiParameter() diff --git a/test/UnitTest/Bootstrap.Admin/Api/HttpHeaderOperationTest.cs b/test/UnitTest/Bootstrap.Admin/Api/HttpHeaderOperationTest.cs new file mode 100644 index 00000000..12b34cec --- /dev/null +++ b/test/UnitTest/Bootstrap.Admin/Api/HttpHeaderOperationTest.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +using Xunit; + +namespace Bootstrap.Admin.Api +{ + public class HttpHeaderOperationTest + { + [Fact] + public void Apply_Ok() + { + var oper = new HttpHeaderOperation(); + var api = new OpenApiOperation(); + var desc = new ApiDescription(); + var mi = typeof(HttpHeaderOperationTest).GetMethod("Apply_Ok"); + var context = new OperationFilterContext(desc, null, null, mi); + oper.Apply(api, context); + } + } +} From 0a563c63062467d557b8aec1b0baea7321fd457a Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 8 Oct 2019 20:43:00 +0800 Subject: [PATCH 3/6] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20DBLog=20?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appveyor.test.ps1 | 2 +- src/admin/Bootstrap.DataAccess/DbManager.cs | 2 +- .../Bootstrap.DataAccess/Helper/LogHelper.cs | 2 +- .../Bootstrap.DataAccess/MongoDB/DBLogTest.cs | 14 ++++++++++ .../Bootstrap.DataAccess/MySql/DBLogTest.cs | 10 +++++++ .../SQLServer/DBLogTest.cs | 28 +++++++++++++++++++ .../Bootstrap.DataAccess/SQLite/DBLogTest.cs | 10 +++++++ 7 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 test/UnitTest/Bootstrap.DataAccess/MongoDB/DBLogTest.cs create mode 100644 test/UnitTest/Bootstrap.DataAccess/MySql/DBLogTest.cs create mode 100644 test/UnitTest/Bootstrap.DataAccess/SQLServer/DBLogTest.cs create mode 100644 test/UnitTest/Bootstrap.DataAccess/SQLite/DBLogTest.cs 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 + { + + } +} From a7bb2bf5e7c5db34e9ee7c0493ce0bb7d259ec56 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Oct 2019 14:57:02 +0800 Subject: [PATCH 4/6] =?UTF-8?q?build:=20=E5=8D=87=E7=BA=A7=20Longbow.Web?= =?UTF-8?q?=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj | 2 +- src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj index 09a783d9..d03fcff4 100644 --- a/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/src/admin/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj index 69f28f73..236d7d29 100644 --- a/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj +++ b/src/admin/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj @@ -16,7 +16,7 @@ - + From 29eb8bc351c5e2cf65096f93ee8bdecc9e972ec2 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Oct 2019 18:26:29 +0800 Subject: [PATCH 5/6] =?UTF-8?q?refactor:=20=E7=BA=A0=E6=AD=A3=20xml=20?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=8F=82=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/Bootstrap.DataAccess/Helper/OAuthHelper.cs | 2 +- src/admin/Bootstrap.DataAccess/Helper/WeChatHelper.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/admin/Bootstrap.DataAccess/Helper/OAuthHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/OAuthHelper.cs index 0b143b83..42156b66 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/OAuthHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/OAuthHelper.cs @@ -74,7 +74,7 @@ namespace Bootstrap.DataAccess /// /// 插入 Gitee 授权用户到数据库中 /// - /// + /// /// private static User ParseUser(OAuthCreatingTicketContext context) { diff --git a/src/admin/Bootstrap.DataAccess/Helper/WeChatHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/WeChatHelper.cs index eeb5b89a..a0400dd5 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/WeChatHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/WeChatHelper.cs @@ -4,6 +4,9 @@ using Longbow.WeChatAuth; using Microsoft.AspNetCore.Authentication.OAuth; using System; using System.Linq; +#if NETCOREAPP3_0 +using System.Text.Json; +#endif namespace Bootstrap.DataAccess { @@ -35,7 +38,7 @@ namespace Bootstrap.DataAccess /// /// 插入 Gitee 授权用户到数据库中 /// - /// + /// /// private static User ParseUser(OAuthCreatingTicketContext context) { @@ -53,7 +56,7 @@ namespace Bootstrap.DataAccess } #if NETCOREAPP3_0 - private static T ToObject(this System.Text.Json.JsonElement element) where T : WeChatUser + private static T ToObject(this JsonElement element) where T : WeChatUser { var user = new WeChatUser(); var target = element.EnumerateObject(); @@ -70,7 +73,7 @@ namespace Bootstrap.DataAccess return user as T; } - private static string TryGetValue(this System.Text.Json.JsonElement.ObjectEnumerator target, string propertyName) + private static string TryGetValue(this JsonElement.ObjectEnumerator target, string propertyName) { var ret = string.Empty; var property = target.FirstOrDefault(t => t.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase)); From 9ef83218f18b09b99d317eb81be683b9ba9e279b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 9 Oct 2019 13:08:54 +0800 Subject: [PATCH 6/6] =?UTF-8?q?build:=20=E6=9B=B4=E6=96=B0=20MySql=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appveyor.test.ps1 | 2 +- appveyor.yml | 4 ++++ db/MySQL/my.ini | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/appveyor.test.ps1 b/appveyor.test.ps1 index 0eefdcf7..d7223364 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 /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=..\..\ + dotnet test test\UnitTest --filter="FullyQualifiedName!~MySql" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Include="[Bootstrap.Admin*]*%2c[Bootstrap.DataAccess*]*" /p:Exclude="[*]*Program%2c[*]*Startup%2c[Bootstrap.DataAccess]*AutoDB%2c[Bootstrap.DataAccess]*WeChatHelper%2c[Bootstrap.DataAccess]*DbLogTask" /p:ExcludeByFile="**/SMSExtensions.cs%2c**/Helper/OAuthHelper.cs" /p:CoverletOutput=..\..\ } function coverallUnitTest() { diff --git a/appveyor.yml b/appveyor.yml index c44b5534..cf7a0c69 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,11 @@ services: - mongodb install: - ps: >- + #copy my.ini into mysql folder + dotnet --version + + #xcopy "$($env:appveyor_build_folder)\db\MySQL\my.ini" "C:\Program Files\MySQL\MySQL Server 5.7" /y build_script: - ps: >- .\appveyor.build.ps1 diff --git a/db/MySQL/my.ini b/db/MySQL/my.ini index eb91891f..9f4ad7e2 100644 --- a/db/MySQL/my.ini +++ b/db/MySQL/my.ini @@ -1,7 +1,9 @@ -[client] +[client] default-character-set=utf8 [mysqld] charcater_set_client=utf8 character_set_connection=utf8 -character_set_results=utf8 \ No newline at end of file +character_set_results=utf8 +character_set_server=utf8 +character_set_database=utf8