Ejemplo n.º 1
0
        public void ParseGpsFix_InvalidValue_ReturnsNull()
        {
            string invalidValue = "some other string";
            GpsFix?parsedValue  = GpxFixHelper.ParseGpsFix(invalidValue);

            Assert.Null(parsedValue);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads waypoint metadata from the internal XmlReader.
        /// </summary>
        /// <param name="metadata">Objecto to store read metadata</param>
        /// <returns>true if piece of metadata was read, otherwise returns false</returns>
        private bool TryReadPointMetadata(GpxPointMetadata metadata)
        {
            switch (_xmlReader.Name)
            {
            case "name":
                metadata.Name = _xmlReader.ReadElementString(); return(true);

            case "cmt":
                metadata.Comment = _xmlReader.ReadElementString(); return(true);

            case "desc":
                metadata.Description = _xmlReader.ReadElementString(); return(true);

            case "src":
                metadata.Source = _xmlReader.ReadElementString(); return(true);

            case "link":
                metadata.Links.Add(ReadLink()); return(true);

            case "magvar":
                string magvarValue = _xmlReader.ReadElementString();
                metadata.MagVar = double.Parse(magvarValue, _invariantCulture); return(true);

            case "geoidheight":
                string geoidHeightValue = _xmlReader.ReadElementString();
                metadata.GeoidHeight = double.Parse(geoidHeightValue, _invariantCulture); return(true);

            case "hdop":
                string HdopValue = _xmlReader.ReadElementString();
                metadata.Hdop = double.Parse(HdopValue, _invariantCulture); return(true);

            case "vdop":
                string vdopValue = _xmlReader.ReadElementString();
                metadata.Vdop = double.Parse(vdopValue, _invariantCulture); return(true);

            case "pdop":
                string pdopValue = _xmlReader.ReadElementString();
                metadata.Pdop = double.Parse(pdopValue, _invariantCulture); return(true);

            case "ageofdgpsdata":
                string ageValue = _xmlReader.ReadElementString();
                metadata.AgeOfDgpsData = double.Parse(ageValue, _invariantCulture); return(true);

            case "sat":
                string satValue = _xmlReader.ReadElementString();
                metadata.SatellitesCount = int.Parse(satValue, _invariantCulture); return(true);

            case "dgpsid":
                string dgpsidValue = _xmlReader.ReadElementString();
                metadata.DgpsId = int.Parse(dgpsidValue, _invariantCulture); return(true);

            case "fix":
                string fixValue = _xmlReader.ReadElementString();
                metadata.Fix = GpxFixHelper.ParseGpsFix(fixValue); return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public void ParseGpsFix_ValidGpsFixes_ParsesStringValue(GpsFix expectedValue, string s)
        {
            GpsFix?parsedValue = GpxFixHelper.ParseGpsFix(s);

            Assert.Equal(expectedValue, parsedValue);
        }