public void GetFieldTTest() { var ltsv = "name:kagawa\tage:26\nname:honda\tage:31\n"; using (var stringReader = new StringReader(ltsv)) using (var ltsvReader = new LtsvReader(stringReader)) { Assert.True(ltsvReader.Read()); Assert.Equal("kagawa", ltsvReader.GetField <string>("name")); Assert.Equal(26, ltsvReader.GetField <int>("age")); Assert.True(ltsvReader.Read()); Assert.Equal(31, ltsvReader.GetField <int>("age")); Assert.Equal("honda", ltsvReader.GetField <string>("name")); Assert.False(ltsvReader.Read()); } }
public void GetFieldTimeTest() { var ltsv = "begin:12:00:00\tend:13:00:00\nbegin:14:00:00\tend:15:00:00\n"; using (var stringReader = new StringReader(ltsv)) using (var ltsvReader = new LtsvReader(stringReader)) { Assert.True(ltsvReader.Read()); Assert.Equal("12:00:00", ltsvReader.GetField("begin")); Assert.Equal("13:00:00", ltsvReader.GetField("end")); Assert.True(ltsvReader.Read()); Assert.Equal("14:00:00", ltsvReader.GetField("begin")); Assert.Equal("15:00:00", ltsvReader.GetField("end")); Assert.False(ltsvReader.Read()); } }
public void GetFieldT_throws_LtsvReaderException_when_has_not_been_read() { var ltsv = "Name:kagawa\tNumber:10\tPosition:MF\r\n"; using (var stringReader = new StringReader(ltsv)) using (var ltsvReader = new LtsvReader(stringReader)) { Assert.Throws <LtsvReaderException>(() => { ltsvReader.GetField <int>("Number"); }); } }