public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { OsmWriterSettings target = new OsmWriterSettings(); target.IsReadOnly = true; Assert.Throws<InvalidOperationException>(() => target.WriteMetadata = true); }
public void ProgramNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { OsmWriterSettings target = new OsmWriterSettings(); target.IsReadOnly = true; Assert.Throws<InvalidOperationException>(() => target.ProgramName = "TEST"); }
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)); }
/// <summary> /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified stream. /// </summary> /// <param name="stream">The Stream to write OSM entities to.</param> /// <param name="settings">The settings defining behaviour of the writer.</param> public OsmXmlWriter(Stream stream, OsmWriterSettings settings) { this.Settings = settings; this.Settings.IsReadOnly = true; _output = stream; _ownsOutputStream = false; XmlWriterSettings writerSetting = new XmlWriterSettings(); writerSetting.Indent = true; _writer = XmlTextWriter.Create(stream, writerSetting); }
/// <summary> /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified file. /// </summary> /// <param name="path">Path to the OSM file.</param> /// <param name="settings">The settings defining behaviour of the writer.</param> /// <remarks>If the file exists, it is overwritten, otherwise, a new file is created.</remarks> public OsmXmlWriter(string path, OsmWriterSettings settings) { this.Settings = settings; this.Settings.IsReadOnly = true; _output = new FileStream(path, FileMode.Create, FileAccess.Write); _ownsOutputStream = true; XmlWriterSettings writerSetting = new XmlWriterSettings(); writerSetting.Indent = true; _streamWriter = new StreamWriter(_output, new UTF8Encoding(false)); _writer = XmlTextWriter.Create(_streamWriter, writerSetting); }
public void Constructor__CreatesSettingsWithDefaultValues() { OsmWriterSettings target = new OsmWriterSettings(); Assert.Equal(true, target.WriteMetadata); }
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); } }