public void FromClrType_maps_floats(object value) { var map = SQLiteTypeMap.FromClrType(value.GetType()); Assert.Equal(SQLiteType.Float, map.SQLiteType); Assert.Equal(3.14, (double)map.ToInterop(value), precision: 6); Assert.Equal(value, map.FromInterop(3.14)); }
public void FromInterop_converts_to_string_when_DateTimeOffset() { var value = new DateTimeOffset(2014, 3, 19, 14, 18, 58, 213, new TimeSpan(-7, 0, 0)); var map = SQLiteTypeMap.FromClrType <DateTimeOffset>(); Assert.Equal(value, map.FromInterop("2014-03-19T14:18:58.2130000-07:00")); }
public void FromInterop_converts_to_string_when_decimal() { var value = 3.14m; var map = SQLiteTypeMap.FromClrType <decimal>(); Assert.Equal(value, map.FromInterop("3.14")); }
public void FromInterop_converts_to_string_when_DateTime() { var value = new DateTime(2014, 3, 19, 14, 18, 58); var map = SQLiteTypeMap.FromClrType <DateTime>(); Assert.Equal(value, map.FromInterop("2014-03-19 14:18:58")); }
public void FromInterop_overflows_when_ulong() { var value = 0xFFFFFFFFFFFFFFFF; var map = SQLiteTypeMap.FromClrType <ulong>(); Assert.Equal(value, map.FromInterop(-1L)); }
public void ToInterop_converts_to_string_when_decimal() { var value = 3.14m; var map = SQLiteTypeMap.FromClrType <decimal>(); Assert.Equal(SQLiteType.Text, map.SQLiteType); Assert.Equal("3.14", map.ToInterop(value)); }
public void ToInterop_converts_to_string_when_TimeSpan() { var value = new TimeSpan(19, 14, 18, 58, 213); var map = SQLiteTypeMap.FromClrType <TimeSpan>(); Assert.Equal(SQLiteType.Text, map.SQLiteType); Assert.Equal("19.14:18:58.2130000", map.ToInterop(value)); }
public void FromClrType_maps_integers(object value) { var map = SQLiteTypeMap.FromClrType(value.GetType()); Assert.Equal(value.GetType(), map.ClrType); Assert.Equal(SQLiteType.Integer, map.SQLiteType); Assert.Equal(1L, map.ToInterop(value)); Assert.Equal(value, map.FromInterop(1L)); }
public void FromInterop_converts_to_string_when_TimeSpan() { var value = new TimeSpan(14, 18, 58); var map = SQLiteTypeMap.FromClrType <TimeSpan>(); Assert.Equal(SQLiteType.Text, map.SQLiteType); Assert.Equal(value, map.FromInterop("14:18:58")); }
public void ToInterop_converts_to_string_when_DateTime() { var value = new DateTime(2014, 3, 19, 14, 18, 58, 213); var map = SQLiteTypeMap.FromClrType <DateTime>(); Assert.Equal(SQLiteType.Text, map.SQLiteType); Assert.Equal("2014-03-19T14:18:58.2130000", map.ToInterop(value)); }
public void FromClrType_maps_dbNull_to_null() { var value = DBNull.Value; var map = SQLiteTypeMap.FromClrType <DBNull>(); Assert.Equal(typeof(DBNull), map.ClrType); Assert.Equal(SQLiteType.Null, map.SQLiteType); Assert.Equal(DBNull.Value, map.ToInterop(value)); Assert.Equal(value, map.FromInterop(DBNull.Value)); }
public void FromClrType_maps_byteArray_to_blob() { var value = new byte[] { 0x7e, 0x57 }; var map = SQLiteTypeMap.FromClrType <byte[]>(); Assert.Equal(typeof(byte[]), map.ClrType); Assert.Equal(SQLiteType.Blob, map.SQLiteType); Assert.Equal(new byte[] { 0x7e, 0x57 }, map.ToInterop(value)); Assert.Equal(value, map.FromInterop(new byte[] { 0x7e, 0x57 })); }
public void FromClrType_maps_string_to_text() { var value = "test"; var map = SQLiteTypeMap.FromClrType <string>(); Assert.Equal(typeof(string), map.ClrType); Assert.Equal(SQLiteType.Text, map.SQLiteType); Assert.Equal("test", map.ToInterop(value)); Assert.Equal(value, map.FromInterop("test")); }
public void FromInterop_converts_to_blob_when_Giud() { var value = new Guid("36127aab-3769-45b5-8804-f2d447dc001a"); var map = SQLiteTypeMap.FromClrType <Guid>(); Assert.Equal( value, map.FromInterop( new byte[] { 0xab, 0x7a, 0x12, 0x36, 0x69, 0x37, 0xb5, 0x45, 0x88, 0x04, 0xf2, 0xd4, 0x47, 0xdc, 0x00, 0x1a })); }
public void FromClrType_handles_enum_types() { Assert.Equal(typeof(int), SQLiteTypeMap.FromClrType(typeof(StringComparison)).ClrType); }
public void FromClrType_handles_nullable_types() { Assert.Equal(typeof(int), SQLiteTypeMap.FromClrType(typeof(int?)).ClrType); }
public void FromClrType_throws_when_unknown() { var ex = Assert.Throws <ArgumentException>(() => SQLiteTypeMap.FromClrType(GetType())); Assert.Equal(Strings.FormatUnknownDataType(GetType()), ex.Message); }