test: 移除 HttpClientFactory 对象引用

This commit is contained in:
Argo Zhang 2019-10-12 22:22:11 +08:00 committed by Argo Zhang
parent a634d9e9e8
commit b0b97db479
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 17 additions and 14 deletions

View File

@ -151,15 +151,16 @@ namespace Bootstrap.DataAccess.SqlServer
{ {
var ipUri = DictHelper.RetrieveLocaleIPSvrUrl("BaiDuIPSvr"); var ipUri = DictHelper.RetrieveLocaleIPSvrUrl("BaiDuIPSvr");
var client = HttpClientFactory.Create(); using (var client = new HttpClient())
{
// 日本东京
var locator = await client.GetAsJsonAsync<BaiDuIPLocator>($"{ipUri}207.148.111.94");
Assert.NotEqual("0", locator.Status);
// 日本东京 // 四川成都
var locator = await client.GetAsJsonAsync<BaiDuIPLocator>($"{ipUri}207.148.111.94"); locator = await client.GetAsJsonAsync<BaiDuIPLocator>($"{ipUri}182.148.123.196");
Assert.NotEqual("0", locator.Status); Assert.Equal("0", locator.Status);
}
// 四川成都
locator = await client.GetAsJsonAsync<BaiDuIPLocator>($"{ipUri}182.148.123.196");
Assert.Equal("0", locator.Status);
} }
[Fact] [Fact]
@ -168,13 +169,15 @@ namespace Bootstrap.DataAccess.SqlServer
var ipUri = DictHelper.RetrieveLocaleIPSvrUrl("JuheIPSvr"); var ipUri = DictHelper.RetrieveLocaleIPSvrUrl("JuheIPSvr");
// 日本东京 // 日本东京
var client = HttpClientFactory.Create(); using (var client = new HttpClient())
var locator = await client.GetAsJsonAsync<JuheIPLocator>($"{ipUri}207.148.111.94"); {
Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code); var locator = await client.GetAsJsonAsync<JuheIPLocator>($"{ipUri}207.148.111.94");
Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code);
// 四川成都 // 四川成都
locator = await client.GetAsJsonAsync<JuheIPLocator>($"{ipUri}182.148.123.196"); locator = await client.GetAsJsonAsync<JuheIPLocator>($"{ipUri}182.148.123.196");
Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code); Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code);
}
} }
[Fact] [Fact]