diff --git a/test/UnitTest/Bootstrap.DataAccess/DictsTest.cs b/test/UnitTest/Bootstrap.DataAccess/DictsTest.cs index 678015bd..ef1fc89f 100644 --- a/test/UnitTest/Bootstrap.DataAccess/DictsTest.cs +++ b/test/UnitTest/Bootstrap.DataAccess/DictsTest.cs @@ -3,6 +3,7 @@ using Bootstrap.Security.Mvc; using Longbow.Web; using Microsoft.Extensions.DependencyInjection; using System; +using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text.Json; @@ -192,6 +193,21 @@ namespace Bootstrap.DataAccess Assert.Contains(new int[] { 0, 10012 }, c => c == locator.Error_Code); } + [Fact] + public async void BaiDu138Svr_Ok() + { + var ipUri = DictHelper.RetrieveLocaleIPSvrUrl("BaiDuIP138Svr"); + + // 日本东京 + using var client = new HttpClient(); + var locator = await client.GetAsJsonAsync($"{ipUri}207.148.111.94"); + Assert.Equal("0", locator.Status); + + // 四川成都 + locator = await client.GetAsJsonAsync($"{ipUri}182.148.123.196"); + Assert.Equal("0", locator.Status); + } + [Fact] public void RetrieveAccessLogPeriod_Ok() { @@ -333,6 +349,37 @@ namespace Bootstrap.DataAccess return Country != "中国" ? $"{Country} {Province} {Isp}" : $"{Province} {City} {Isp}"; } } + + private class BaiduIP138Locator + { + /// + /// + /// + public string Status { get; set; } = ""; + + /// + /// 获得/设置 地理位置结果 + /// + public IEnumerable Data { get; set; } = new BaiDuIp138LocatorResult[0]; + } + + /// + /// Ip138 地理位置结果实体类 + /// + private class BaiDuIp138LocatorResult + { + /// + /// 获得/设置 地理位置信息 + /// + public string Location { get; set; } = ""; + + /// + /// ToString 方法 + /// + /// + public override string ToString() => Location; + } + #endregion } }