public void TestStringDataContents(SqliteEncoding encoding, int id, string expectedLanguage, string expectedString) { using (Sqlite3Database db = new Sqlite3Database(Get(encoding))) { Sqlite3Table tbl = db.GetTable("EncodingTable" + encoding); Sqlite3Row row = tbl.GetRowById(id); Assert.NotNull(row); Assert.True(row.TryGetOrdinal(1, out string actualLang)); Assert.True(row.TryGetOrdinal(2, out string actualText)); Assert.Equal(expectedLanguage, actualLang); Assert.Equal(expectedString, actualText); } }
public void TestIntegerData(int id, long expected) { using (Sqlite3Database db = new Sqlite3Database(_stream)) { Sqlite3Table tbl = db.GetTable("IntegerTable"); Sqlite3Row row = tbl.GetRowById(id); Assert.NotNull(row); Assert.True(row.TryGetOrdinal(1, out long actual)); Assert.Equal(expected, actual); } }
public void TestIntegerData(int id, long expectedInteger, long?expectedNewInteger) { using (Sqlite3Database db = new Sqlite3Database(_stream)) { Sqlite3Table tbl = db.GetTable("MyTable"); Sqlite3Row row = tbl.GetRowById(id); Assert.NotNull(row); Assert.True(row.TryGetOrdinal(1, out long actual)); Assert.Equal(expectedInteger, actual); if (expectedNewInteger.HasValue) { Assert.True(row.TryGetOrdinal(2, out long actualOther)); Assert.Equal(expectedNewInteger.Value, actualOther); } else { Assert.False(row.TryGetOrdinal(2, out long _)); } } }
public void TestLongText() { using (Sqlite3Database db = new Sqlite3Database(_stream)) { Sqlite3Table tbl = db.GetTable("urls"); List <Sqlite3Row> rows = tbl.EnumerateRows().ToList(); Assert.Single(rows); Sqlite3Row row = rows.Single(); Assert.Equal(6014, row.RowId); Assert.True(row.TryGetOrdinal(1, out string actual)); Assert.Equal(_expected, actual); } }
public void TestRealData() { using (Sqlite3Database db = new Sqlite3Database(_stream)) { Sqlite3Table tbl = db.GetTable("DataTable"); List <Sqlite3Row> rows = tbl.EnumerateRows().ToList(); Assert.Single(rows); Sqlite3Row row = rows.Single(); Assert.Equal(1, row.RowId); Assert.True(row.TryGetOrdinal(1, out byte[] actual)); Assert.Equal(_expected, actual); } }
public void TestRealData(int id, long expectedLong) { using (Sqlite3Database db = new Sqlite3Database(_stream)) { Sqlite3Table tbl = db.GetTable("RealTable"); Sqlite3Row row = tbl.GetRowById(id); Assert.NotNull(row); Assert.True(row.TryGetOrdinal(1, out double actual)); long actualLong = BitConverter.DoubleToInt64Bits(actual); // Note: There is a loss of precision in the sqlite3 cli when generating the test database // This, and the similar loss of precision in C# / floating points here leads to the code below Assert.True(Math.Abs(expectedLong - actualLong) <= 2); } }