public void Constructor_CreatesEmptyDocument() { var target = new GpxDocument(); Assert.Empty(target.Waypoints); Assert.Empty(target.Routes); Assert.Empty(target.Tracks); }
/// <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; }
/// <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); }
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); }
/// <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); }
/// <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; }
public void Save_ThrowsExceptionIfPathIsNull() { string path = null; var target = new GpxDocument(); Assert.Throws<ArgumentNullException>(() => target.Save(path)); }
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()); }
public void Save_IGpxWriter_ThrowsExceptionIfWriterIsNull() { IGpxWriter writer = null; var target = new GpxDocument(); Assert.Throws<ArgumentNullException>(() => target.Save(writer)); }