/// <summary>
        /// Initializes a new instance of the <see cref="CsvWriter"/> class.
        /// </summary>
        /// <param name="textWriter">The <see cref="ITextWriter"/> to take ownership of.</param>
        /// <param name="format">The <see cref="CsvFormat"/> to use.</param>
        public CsvWriter( ITextWriter textWriter, CsvFormat format )
        {
            Ensure.That(textWriter).NotNull();
            Ensure.That(format).NotNull();

            this.csvFormat = format;
            this.tw = textWriter;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CsvReader"/> class.
        /// </summary>
        /// <param name="textReader">The <see cref="ITextReader"/> to take ownership of.</param>
        /// <param name="format">The <see cref="CsvFormat"/> to use.</param>
        public CsvReader( ITextReader textReader, CsvFormat format )
        {
            Ensure.That(textReader).NotNull();
            Ensure.That(format).NotNull();

            this.csvFormat = format;
            this.sb = new StringBuilder();
            this.record = new List<Substring>();
            this.readOnlyRecord = new ReadOnlyList.Wrapper<Substring>(this.record);
            this.tr = textReader;
        }
        private static string Write( CsvFormat csvFormat, Action<CsvWriter> action )
        {
            var sw = new StringWriter();
            using( var writer = new CsvWriter(sw, csvFormat) )
            {
                action(writer);

                sw.Flush();
                return sw.ToString();
            }
        }
        private static void Read( CsvFormat csvFormat, string content, params Action<Substring[]>[] actions )
        {
            var sr = new StringReader(content);
            using( var reader = new CsvReader(sr, csvFormat) )
            {
                foreach( var a in actions )
                {
                    Assert.True(reader.Read());

                    Assert.NotNull(reader.Record);
                    a(reader.Record.ToArray());
                }

                Assert.False(reader.Read());
            }
        }