Example #1
0
        public void GpxWritev1_1Test()
        {
            // instantiate and load the gpx test document.
            XmlStreamSource source = new XmlStreamSource(
                Assembly.GetExecutingAssembly().GetManifestResourceStream("OsmSharp.UnitTests.test.v1.1.gpx"));
            GpxDocument document = new GpxDocument(source);
            object      gpx      = document.Gpx;

            if (gpx is OsmSharp.Xml.Gpx.v1_1.gpxType)
            { // all ok here!
                // get the target file.
                MemoryStream write_file = new MemoryStream();

                // create a new xml source.
                XmlStreamSource write_source = new XmlStreamSource(write_file);
                GpxDocument     gpx_target   = new GpxDocument(write_source);

                // set the target data the same as the source document.
                gpx_target.Gpx = gpx;

                // save the data.
                gpx_target.Save();

                // close the old document.
                document.Close();
                source.Close();

                // check to see if the data was writter correctly.
                // instantiate and load the gpx test document.
                source   = new XmlStreamSource(write_file);
                document = new GpxDocument(source);
                gpx      = document.Gpx;
                if (gpx is OsmSharp.Xml.Gpx.v1_1.gpxType)
                { // all ok here!
                    OsmSharp.Xml.Gpx.v1_1.gpxType gpx_type = (gpx as OsmSharp.Xml.Gpx.v1_1.gpxType);

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

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

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

                // test the gpx test file content.
                Assert.IsNotNull(gpx_type.trk, "Gpx has no track!");
                Assert.AreEqual(gpx_type.trk[0].trkseg.Length, 1, "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();
        }