更新IP地址库
大石头 authored at 2021-05-22 16:28:26
1.36 KiB
X
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewLife;
using Xunit;

namespace XUnitTest.Applications
{
    public class IpTests
    {
        //static IpTests()
        //{
        //    Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
        //}

        [Fact]
        public void Test1()
        {
            var addr = "39.144.10.35".IPToAddress();
            var ss = addr.Split(' ');
            Assert.Equal("北京市", ss[0]);

            addr = "116.234.91.199".IPToAddress();
            ss = addr.Split(' ');
            Assert.Equal("上海市", ss[0]);

            addr = "61.160.219.25".IPToAddress();
            ss = addr.Split(' ');
            Assert.Equal("江苏省常州市武进区", ss[0]);

            addr = "123.14.85.208".IPToAddress();
            ss = addr.Split(' ');
            Assert.Equal("河南省郑州市", ss[0]);

            addr = "113.220.60.29".IPToAddress();
            ss = addr.Split(' ');
            Assert.Equal("湖南省张家界市", ss[0]);

            addr = "124.239.170.77".IPToAddress();
            ss = addr.Split(' ');
            Assert.Equal("河北省衡水市", ss[0]);

            addr = "112.74.79.65".IPToAddress();
            ss = addr.Split(' ');
            Assert.Equal("广东省深圳市", ss[0]);
        }
    }
}