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(); }
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); }
public SxGeoTests(TestsFixture data) { sxGeo = data.SxGeo; }
public void ReadHeaderTest() { SxGeo sxGeo = new SxGeo(); //Assert.Equal("SxH", sxGeo.Header.Identifier); }
public void ReadHeaderCityTest() { SxGeo sxGeo = new SxGeo("./Resources/SxGeoCity.dat"); //Assert.Equal("SxG", sxGeo.Header.Identifier); }
public TestsFixture() { var dir = Path.GetFullPath(Environment.CurrentDirectory); this.SxGeo = new SxGeo(Path.Combine(ScanDir(dir), "SxGeo.dat")); }