Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
        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);
        }