コード例 #1
0
        public void NextRecordTest()
        {
            var sb = new StringBuilder();

            using (var stringWriter = new StringWriter(sb))
                using (var ltsvWriter = new LtsvWriter(stringWriter))
                {
                    ltsvWriter.WriteField("name", "kagawa");
                    ltsvWriter.WriteField("age", 26);
                    ltsvWriter.NextRecord();
                    ltsvWriter.WriteField("name", "honda");
                    ltsvWriter.WriteField("age", 31);
                    ltsvWriter.NextRecord();
                }

            Assert.Equal("name:kagawa\tage:26\r\nname:honda\tage:31\r\n", sb.ToString());
        }
コード例 #2
0
 public void NextRecord_throws_LtsvWriterException_when_an_unexpected_error_occurred()
 {
     using (var textWriter = new DummyTextWriter())
         using (var ltsvWriter = new LtsvWriter(textWriter))
         {
             ltsvWriter.WriteField("foo", "bar");
             Assert.Throws <LtsvWriterException>(() =>
             {
                 ltsvWriter.NextRecord();
             });
         }
 }
コード例 #3
0
        public void WriteFieldTest()
        {
            var sb = new StringBuilder();

            using (var stringWriter = new StringWriter(sb))
                using (var ltsvWriter = new LtsvWriter(stringWriter))
                {
                    ltsvWriter.WriteField("name", "ichiro");
                    ltsvWriter.WriteField("age", "42");
                    ltsvWriter.NextRecord();
                }

            Assert.Equal("name:ichiro\tage:42\r\n", sb.ToString());
        }