public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() { string path = "TestFiles\\xmlwriter-constructor-test.osm"; OsmWriterSettings settings = new OsmWriterSettings(); using (OsmXmlWriter target = new OsmXmlWriter(path, settings)) { Assert.Same(settings, target.Settings); Assert.True(target.Settings.IsReadOnly); } }
public void Constructor_PathSettings_CreatesOutputFile() { string filename = "TestFiles\\osmwriter-constructor-creates-output-test.pbf"; File.Delete(filename); OsmWriterSettings settings = new OsmWriterSettings(); using (OsmXmlWriter target = new OsmXmlWriter(filename, settings)) { ; } Assert.True(File.Exists(filename)); }
public void XmlOsmWriterWritesFilesCompatibleWithOsmosis() { string xmlFile = Path.GetFullPath("TestFiles\\xmlwriter-osmosis-compatibility-test-xmlwriter-real-file.osm"); if (File.Exists(xmlFile)) { File.Delete(xmlFile); } using (OsmXmlWriter writer = new OsmXmlWriter(xmlFile, new OsmWriterSettings() { WriteMetadata = true })) { foreach (var entityInfo in this.GetTestData()) { writer.Write(entityInfo); } } string osmosisXmlFile = Path.GetFullPath("TestFiles\\xmlwriter-osmosis-compatibility-test-test-file.osm"); if (File.Exists(osmosisXmlFile)) { File.Delete(osmosisXmlFile); } string osmosisArguments = string.Format("--read-xml file={0} --write-xml file={1}", xmlFile, osmosisXmlFile); this.CallOsmosis(osmosisArguments); Assert.True(File.Exists(osmosisXmlFile)); Assert.True(new FileInfo(osmosisXmlFile).Length > 0); }
public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() { MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { Assert.Throws<ArgumentException>(() => target.Write(_node)); } }
public void Write_IOsmGeometry_WritesWay() { Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(way); } this.TestXmlOutput(stream, new WayInfo(way), false); }
public void Write_IOsmGeometry_WritesRelation() { Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(relation); } this.TestXmlOutput(stream, new RelationInfo(relation), false); }
public void Write_IOsmGeometry_WritesNode() { Node node = new Node(1, 11.1, 12.1); MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(node); } this.TestXmlOutput(stream, new NodeInfo(node), false); }
public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() { MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { IOsmGeometry entity = null; Assert.Throws<ArgumentNullException>(() => target.Write(entity)); } }
public void Write_IEntityInfo_WritesWayWithMetadata() { MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { target.Write(_wayProperties); } this.TestXmlOutput(stream, _wayProperties, true); }
public void Write_IEntityInfo_WritesRelationWithWay() { MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_relationWay); } this.TestXmlOutput(stream, _relationWay, false); }
public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMedataIsFalse() { MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_wayProperties); } stream = new MemoryStream(stream.GetBuffer()); using (TextReader reader = new StreamReader(stream)) { string line = null; while ((line = reader.ReadLine()) != null) { Assert.DoesNotContain("timestamp", line); } } }
public void Write_DoesNotThrowsExceptionIfMetadataContainsNullInsteadUsername() { MemoryStream stream = new MemoryStream(); _nodeProperties.Metadata.User = null; using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { Assert.DoesNotThrow(() => target.Write(_nodeProperties)); } }
public void Dispose_ClosesOutputStreamIfWritingToStream() { MemoryStream stream = new MemoryStream(); OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings()); target.Dispose(); Assert.False(stream.CanRead); }
public void Dispose_ClosesOutputStreamIfWritingToFiles() { string path = "TestFiles\\xmlwriter-closes-output-filestream-test.osm"; File.Delete(path); OsmXmlWriter target = new OsmXmlWriter(path, new OsmWriterSettings()); target.Dispose(); FileStream testStream = null; Assert.DoesNotThrow(() => testStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite)); testStream.Dispose(); }
public void Write_IEntityInfo_WritesWayWithTags() { MemoryStream stream = new MemoryStream(); using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_wayTags); } this.TestXmlOutput(stream, _wayTags, false); }
public void Constructor_StreamSettings_SetsSettingsAndMakesThemReadOnly() { MemoryStream stream = new MemoryStream(); OsmWriterSettings settings = new OsmWriterSettings(); using (OsmXmlWriter target = new OsmXmlWriter(stream, settings)) { Assert.Same(settings, target.Settings); Assert.True(target.Settings.IsReadOnly); } }
static void TestXmlWriterSpeedWithoutMetadata() { using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) { foreach (var entity in _entities) { writer.Write(entity); } } }