From b0b97db4799dbf5d4792962cbeccf577cb884ae8 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 12 Oct 2019 22:22:11 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E7=A7=BB=E9=99=A4=20HttpClientFactory?= =?UTF-8?q?=20=E5=AF=B9=E8=B1=A1=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SQLServer/DictsTest.cs | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/test/UnitTest/Bootstrap.DataAccess/SQLServer/DictsTest.cs b/test/UnitTest/Bootstrap.DataAccess/SQLServer/DictsTest.cs index fb468224..5b60372c 100644 --- a/test/UnitTest/Bootstrap.DataAccess/SQLServer/DictsTest.cs +++ b/test/UnitTest/Bootstrap.DataAccess/SQLServer/DictsTest.cs @@ -151,15 +151,16 @@ namespace Bootstrap.DataAccess.SqlServer { var ipUri = DictHelper.RetrieveLocaleIPSvrUrl("BaiDuIPSvr"); - var client = HttpClientFactory.Create(); + using (var client = new HttpClient()) + { + // 日本东京 + var locator = await client.GetAsJsonAsync($"{ipUri}207.148.111.94"); + Assert.NotEqual("0", locator.Status); - // 日本东京 - var locator = await client.GetAsJsonAsync($"{ipUri}207.148.111.94"); - Assert.NotEqual("0", locator.Status); - - // 四川成都 - locator = await client.GetAsJsonAsync($"{ipUri}182.148.123.196"); - Assert.Equal("0", locator.Status); + // 四川成都 + locator = await client.GetAsJsonAsync($"{ipUri}182.148.123.196"); + Assert.Equal("0", locator.Status); + } } [Fact] @@ -168,13 +169,15 @@ namespace Bootstrap.DataAccess.SqlServer var ipUri = DictHelper.RetrieveLocaleIPSvrUrl("JuheIPSvr"); // 日本东京 - var client = HttpClientFactory.Create(); - var locator = await client.GetAsJsonAsync($"{ipUri}207.148.111.94"); - Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code); + using (var client = new HttpClient()) + { + var locator = await client.GetAsJsonAsync($"{ipUri}207.148.111.94"); + Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code); - // 四川成都 - locator = await client.GetAsJsonAsync($"{ipUri}182.148.123.196"); - Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code); + // 四川成都 + locator = await client.GetAsJsonAsync($"{ipUri}182.148.123.196"); + Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code); + } } [Fact]