public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly()
        {
            var target = new GpxWriterSettings();
            target.IsReadOnly = true;

            Assert.Throws<InvalidOperationException>(() => target.WriteMetadata = true);
        }
        public void GeneratorNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly()
        {
            var target = new GpxWriterSettings();
            target.IsReadOnly = true;

            Assert.Throws<InvalidOperationException>(() => target.GeneratorName = "TEST");
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified file.
        /// </summary>
        /// <param name="path">Path to the GPX 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 GpxWriter(string path, GpxWriterSettings settings)
        {
            this.Settings = settings;
            settings.IsReadOnly = true;

            XmlWriterSettings writerSetting = new XmlWriterSettings();
            writerSetting.Indent = true;

            _streamWriter = new StreamWriter(path, false, new UTF8Encoding(false));
            _xmlWriter = XmlTextWriter.Create(_streamWriter, writerSetting);

            StartDocument();
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified stream.
        /// </summary>
        /// <param name="stream">The Stream to write GPX entities to.</param>
        /// <param name="settings">The settings defining behaviour of the writer.</param>
        public GpxWriter(Stream stream, GpxWriterSettings settings)
        {
            this.Settings       = settings;
            settings.IsReadOnly = true;

            XmlWriterSettings writerSetting = new XmlWriterSettings();

            writerSetting.Indent = true;

            _streamWriter = new StreamWriter(stream, new UTF8Encoding(false));
            _xmlWriter    = XmlWriter.Create(_streamWriter, writerSetting);

            StartDocument();
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified file.
        /// </summary>
        /// <param name="path">Path to the GPX 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 GpxWriter(string path, GpxWriterSettings settings)
        {
            this.Settings       = settings;
            settings.IsReadOnly = true;

            XmlWriterSettings writerSetting = new XmlWriterSettings();

            writerSetting.Indent = true;

            var fileStream = new FileStream(path, FileMode.Create);

            _streamWriter = new StreamWriter(fileStream, new UTF8Encoding(false));
            _xmlWriter    = XmlWriter.Create(_streamWriter, writerSetting);

            StartDocument();
        }
예제 #6
0
 public void Constructor_StreamSettings_SetsSettingsAndMarkSettingsAsReadOnly()
 {
     var stream = new MemoryStream();
     var settings = new GpxWriterSettings();
     using (var target = new GpxWriter(stream, settings)) {
         Assert.Same(settings, target.Settings);
         Assert.True(target.Settings.IsReadOnly);
     }
 }
예제 #7
0
 public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly()
 {
     string path = "TestFiles\\gpxwriter-constructor-test.gpx";
     var settings = new GpxWriterSettings();
     using (var target = new GpxWriter(path, settings)) {
         Assert.Same(settings, target.Settings);
         Assert.True(target.Settings.IsReadOnly);
     }
 }
예제 #8
0
        public void Constructor_PathSettings_CreatesOutputFile()
        {
            string filename = "TestFiles\\gpxwriter-constructor-creates-output-test.gpx";
            File.Delete(filename);

            var settings = new GpxWriterSettings();
            using (var target = new GpxWriter(filename, settings)) {
                ;
            }

            Assert.True(File.Exists(filename));
        }
        public void Constructor__CreatesSettingsWithDefaultValues()
        {
            var target = new GpxWriterSettings();

            Assert.Equal(true, target.WriteMetadata);
        }