예제 #1
0
        public void Constructor_CreatesEmptyDocument()
        {
            var target = new GpxDocument();

            Assert.Empty(target.Waypoints);
            Assert.Empty(target.Routes);
            Assert.Empty(target.Tracks);
        }
예제 #2
0
        /// <summary>
        /// Loads Gpx data from a file.
        /// </summary>
        /// <param name="path">Path to the GPX file.</param>
        /// <returns>GpxDocument instance with data from GPX file</returns>
        public static GpxDocument Load(string path)
        {
            GpxDocument result = new GpxDocument();

            using (GpxReader reader = new GpxReader(path, new GpxReaderSettings() { ReadMetadata = true })) {
                result.LoadFromReader(reader);
            }

            return result;
        }
예제 #3
0
        /// <summary>
        /// Loads Gpx data from IGpxReader
        /// </summary>
        /// <param name="reader">The reader to read data from</param>
        /// <returnsGpxDocument instance eith data from GpxReader></returns>
        public static GpxDocument Load(IGpxReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            GpxDocument result = new GpxDocument();

            result.LoadFromReader(reader);
            return(result);
        }
예제 #4
0
        public void Constructor_WaypointsRoutesTracks_CreatesDocumentWithGpxEntities()
        {
            IEnumerable<GpxPoint> waypoints = new[] { new GpxPoint() };
            IEnumerable<GpxRoute> routes = new[] { new GpxRoute() };
            IEnumerable<GpxTrack> tracks = new[] { new GpxTrack() };

            var target = new GpxDocument(waypoints, routes, tracks);

            Assert.Equal(waypoints, target.Waypoints);
            Assert.Equal(routes, target.Routes);
            Assert.Equal(tracks, target.Tracks);
        }
예제 #5
0
        /// <summary>
        /// Loads Gpx data from a file.
        /// </summary>
        /// <param name="path">Path to the GPX file.</param>
        /// <returns>GpxDocument instance with data from GPX file</returns>
        public static GpxDocument Load(string path)
        {
            GpxDocument result = new GpxDocument();

            using (GpxReader reader = new GpxReader(path, new GpxReaderSettings()
            {
                ReadMetadata = true
            })) {
                result.LoadFromReader(reader);
            }

            return(result);
        }
예제 #6
0
        /// <summary>
        /// Loads Gpx data from IGpxReader
        /// </summary>
        /// <param name="reader">The reader to read data from</param>
        /// <returnsGpxDocument instance eith data from GpxReader></returns>
        public static GpxDocument Load(IGpxReader reader)
        {
            if (reader == null) {
                throw new ArgumentNullException("reader");
            }

            GpxDocument result = new GpxDocument();
            result.LoadFromReader(reader);
            return result;
        }
예제 #7
0
        public void Save_ThrowsExceptionIfPathIsNull()
        {
            string path = null;
            var target = new GpxDocument();

            Assert.Throws<ArgumentNullException>(() => target.Save(path));
        }
예제 #8
0
        public void Save_IGpxWriter_WritesDataToWriter()
        {
            var waypoint = new GpxPoint();
            var route = new GpxRoute();
            var track = new GpxTrack();

            Mock<IGpxWriter> writerM = new Mock<IGpxWriter>();
            writerM.Setup(w => w.Write(waypoint)).Verifiable();
            writerM.Setup(w => w.Write(route)).Verifiable();
            writerM.Setup(w => w.Write(track)).Verifiable();

            var target = new GpxDocument(new[] { waypoint }, new[] { route }, new[] { track });
            target.Save(writerM.Object);

            writerM.Verify(w => w.Write(waypoint), Times.Once());
            writerM.Verify(w => w.Write(route), Times.Once());
            writerM.Verify(w => w.Write(track), Times.Once());
        }
예제 #9
0
        public void Save_IGpxWriter_ThrowsExceptionIfWriterIsNull()
        {
            IGpxWriter writer = null;

            var target = new GpxDocument();
            Assert.Throws<ArgumentNullException>(() => target.Save(writer));
        }