public void ExceptionWithOffsetGreatedObjectSizeTest() { var binary = GeoBaseTestData.GetBinaryGeoBase(); var converter = new ConverterService(); Assert.Throws <ArgumentOutOfRangeException>(() => converter.ConvertToCity(binary, binary.Length - 10)); Assert.Throws <ArgumentOutOfRangeException>(() => converter.ConvertToHeader(binary, binary.Length - 10)); }
public void ConvertCorrectBinaryToHeader() { var binary = GeoBaseTestData.GetBinaryGeoBase(); var converter = new ConverterService(); var header = converter.ConvertToHeader(binary, 0); Assert.Equal(header.Version, 1); Assert.Equal(header.Name, GeoBaseTestData.DbName); }
public void ConvertCorrectBinaryToCity() { var binary = GeoBaseTestData.GetBinaryGeoBase(); var converter = new ConverterService(); var header = converter.ConvertToHeader(binary, 0); var firstCity = converter.ConvertToCity(binary, (int)header.OffsetLocations); var secondCity = converter.ConvertToCity(binary, (int)header.OffsetLocations + Constants.CitySize); Assert.Equal(firstCity.CityName, "cit_1"); Assert.Equal(secondCity.CityName, "cit_2"); }
public void ReadAndCheckDataTest() { var binary = fileReadServiceMock.Object.ReadAllBytes("secret"); var converter = new ConverterService(); var header = converter.ConvertToHeader(binary, 0); var firstIpFrom = BitConverter.ToInt32(binary, (int)header.OffsetRanges); var firstCity = converter.ConvertToCity(binary, (int)header.OffsetLocations); var secondIndex = BitConverter.ToInt32(binary, (int)header.OffsetCities + Constants.IndexSize); Assert.Equal(header.Name, GeoBaseTestData.DbName); Assert.Equal <int>(8, firstIpFrom); Assert.Equal("cit_1", firstCity.CityName); Assert.Equal(1, secondIndex); }