public void RoundTripTest(string path) { var file = GpxFile.ReadFrom(XmlReader.Create(path), null); using (var ms = new MemoryStream()) { var writerSettings = new XmlWriterSettings { Encoding = Encoding.UTF8, CloseOutput = false }; using (var wr = XmlWriter.Create(ms, writerSettings)) { file.WriteTo(wr, null); } ms.Position = 0; byte[] expected = File.ReadAllBytes(path); var diff = DiffBuilder.Compare(expected) .NormalizeWhitespace() .WithTest(ms) .IgnoreComments() .CheckForSimilar() .Build(); // note that this is not a guarantee in the general case. the inputs here have all been // slightly tweaked such that it should succeed for our purposes. Assert.False(diff.HasDifferences(), string.Join(Environment.NewLine, diff.Differences)); } }
public void DefaultInstanceShouldBeValid() { var file = new GpxFile(); using (var ms = new MemoryStream()) { var writerSettings = new XmlWriterSettings { Encoding = Encoding.UTF8, CloseOutput = false }; using (var wr = XmlWriter.Create(ms, writerSettings)) { file.WriteTo(wr, null); } ms.Position = 0; file = GpxFile.ReadFrom(XmlReader.Create(ms), null); Assert.NotNull(file); Assert.Equal("NetTopologySuite.IO.GPX", file.Metadata.Creator); Assert.True(file.Metadata.IsTrivial); Assert.Empty(file.Waypoints); Assert.Empty(file.Routes); Assert.Empty(file.Tracks); Assert.Null(file.Extensions); } }