Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
Dim field As Integer = 0
Dim buf As Byte() = New Byte(10) {}
Dim ch As Char() = New Char(10) {}
Assert.IsTrue(r.Read())
Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
Assert.AreEqual(DirectCast(0, Byte), buf(3))
Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
Assert.AreEqual("string", New [String](ch, 0, 6))
Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
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))
End Using
Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
Assert.AreEqual(0.25F, r.GetFloat(field))
Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using |