Пример #1
0
        public void GetIpTestFull()
        {
            SxGeo sxGeo = new SxGeo("./Resources/SxGeoCity.dat");

            Assert.Equal("RU", sxGeo.GetCountry(IPAddress.Parse("95.24.17.92")));
            var countryid = sxGeo.GetCountryId(IPAddress.Parse("95.24.17.92"));
            var city      = sxGeo.GetCity(IPAddress.Parse("95.24.17.92"));
            var cityFull  = sxGeo.GetCityFull(IPAddress.Parse("95.24.17.92"));
            var num       = sxGeo.GetNumber(IPAddress.Parse("95.24.17.92"));
            var about     = sxGeo.About();
        }
Пример #2
0
        public SxGeoProvider(ICountryResolverOptions options, ILogger <SxGeoProvider> logger)
        {
            this.logger = logger;
            if (options.DownloadOnStart || !File.Exists(options.Path))
            {
                SxGeoDownloader downloader = new SxGeoDownloader(options.URL, options.Path, true);
                if (!downloader.Download())
                {
                    // for strage case with certificate, use last database
                    if (File.Exists(options.Path))
                    {
                        logger?.LogError(new FileNotFoundException("Can't download database!"), "[ALERT] Can't download database! For strage case with certificate, use last database!");
                    }
                    else
                    {
                        // if you get a throw check this line
                        throw new FileNotFoundException("Can't download database!");
                    }
                }
            }

            sxGeo = new SxGeo(options.Path);
        }
Пример #3
0
 public SxGeoTests(TestsFixture data)
 {
     sxGeo = data.SxGeo;
 }
Пример #4
0
        public void ReadHeaderTest()
        {
            SxGeo sxGeo = new SxGeo();

            //Assert.Equal("SxH", sxGeo.Header.Identifier);
        }
Пример #5
0
        public void ReadHeaderCityTest()
        {
            SxGeo sxGeo = new SxGeo("./Resources/SxGeoCity.dat");

            //Assert.Equal("SxG", sxGeo.Header.Identifier);
        }
Пример #6
0
        public TestsFixture()
        {
            var dir = Path.GetFullPath(Environment.CurrentDirectory);

            this.SxGeo = new SxGeo(Path.Combine(ScanDir(dir), "SxGeo.dat"));
        }