Esempio n. 1
0
        public void KmlReadTestv2_0()
        {
            // instantiate and load the gpx test document.
            XmlStreamSource source = new XmlStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.UnitTests.test.v2.0.kml"));
            KmlDocument document = new KmlDocument(source);
            object kml = document.Kml;

            if (kml is OsmSharp.Tools.Xml.Kml.v2_0.kml)
            { // all ok here!
                OsmSharp.Tools.Xml.Kml.v2_0.kml kml_type = (kml as OsmSharp.Tools.Xml.Kml.v2_0.kml);

                // test the gpx test file content.
                Assert.IsNotNull(kml_type.Item, "No item was found!");
                Assert.IsInstanceOf<OsmSharp.Tools.Xml.Kml.v2_0.Placemark>(kml_type.Item, "Incorrect item type!");

                OsmSharp.Tools.Xml.Kml.v2_0.Placemark type = (kml_type.Item as OsmSharp.Tools.Xml.Kml.v2_0.Placemark);
                Assert.AreEqual(type.Items.Length, 3, "Incorrect number of items in folder!");
            }
            else
            {
                Assert.Fail("No kml data was read, or data was of the incorrect type!");
            }

            document.Close();
            source.Close();
        }
Esempio n. 2
0
        public void GpxReadv1_0Test()
        {
            // instantiate and load the gpx test document.
            XmlStreamSource source = new XmlStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.UnitTests.test.v1.0.gpx"));
            GpxDocument document = new GpxDocument(source);
            object gpx = document.Gpx;

            if (gpx is OsmSharp.Tools.Xml.Gpx.v1_0.gpx)
            { // all ok here!
                OsmSharp.Tools.Xml.Gpx.v1_0.gpx gpx_type = (gpx as OsmSharp.Tools.Xml.Gpx.v1_0.gpx);

                // test the gpx test file content.
                Assert.IsNotNull(gpx_type.trk, "Gpx has not track!");
                Assert.AreEqual(gpx_type.trk[0].trkseg.Length, 424, "Not the correct number of track segments found!");
            }
            else
            {
                Assert.Fail("No gpx data was read, or data was of the incorrect type!");
            }

            document.Close();
            source.Close();
        }