public void TestValueTypes() { string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"; using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None)) { int field = 0; byte[] buf = new byte[10]; char[] ch = new char[10]; Assert.IsTrue(r.Read()); Assert.AreEqual(true, r.GetBoolean(field++)); Assert.AreEqual((byte)129, r.GetByte(field++)); Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length)); Assert.AreEqual((byte)0xf0, buf[0]); Assert.AreEqual((byte)0xa1, buf[1]); Assert.AreEqual((byte)0x2b, buf[2]); Assert.AreEqual((byte)0, buf[3]); Assert.AreEqual('a', r.GetChar(field++)); Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length)); Assert.AreEqual("string", new String(ch, 0, 6)); using (IDataReader c = r.GetData(field++)) { Assert.AreEqual(1, c.Depth); Assert.AreEqual(0, c.FieldCount); Assert.IsTrue(c.Read()); Assert.AreEqual(3, c.FieldCount); Assert.AreEqual("a", c.GetString(0)); Assert.AreEqual("b", c.GetString(1)); Assert.AreEqual("c", c.GetString(2)); } Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++)); Assert.AreEqual((decimal)0.25, r.GetDecimal(field)); Assert.AreEqual(0.25f, r.GetFloat(field)); Assert.AreEqual(0.25, r.GetDouble(field++)); Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++)); Assert.AreEqual((short)20000, r.GetInt16(field++)); Assert.AreEqual(-2000000000, r.GetInt32(field++)); Assert.AreEqual(2000000000000L, r.GetInt64(field++)); } }