优化单元测试,降低环境影响
大石头 authored at 2021-08-06 22:50:52
725.00 B
X
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewLife.Http;
using NewLife.Yun;
using Xunit;
using NewLife;

namespace XUnitTest.Yun
{
    public class BaiduMapTests
    {
        [Fact]
        public async void IpLocation()
        {
            var html = new TinyHttpClient().GetString("http://myip.ipip.net");
            var ip = html?.Substring("IP:", " ");
            Assert.NotEmpty(ip);

            var map = new BaiduMap();
            var rs = await map.IpLocationAsync(ip);

            Assert.NotNull(rs);

            var addrs = (rs["full_address"] + "").Split('|');
            Assert.Equal(7, addrs.Length);
        }
    }
}