private void compare(ISQLiteValue expected, ISQLiteValue test) { Assert.Equal(test.Length, expected.Length); Assert.Equal(test.SQLiteType, expected.SQLiteType); Assert.Equal(test.ToDouble(), expected.ToDouble(), 15); Assert.Equal(test.ToInt64(), expected.ToInt64()); Assert.Equal(test.ToInt(), expected.ToInt()); Assert.Equal(test.ToString(), expected.ToString()); Assert.Equal(test.ToBlob().ToArray(), expected.ToBlob().ToArray()); }
private void compare(ISQLiteValue expected, ISQLiteValue test) { Assert.Equal(expected.Length, test.Length); Assert.Equal(expected.SQLiteType, test.SQLiteType); // FIXME: Testing double equality is imprecise //Assert.Equal(expected.ToDouble(), test.ToDouble()); Assert.Equal(expected.ToInt64(), test.ToInt64()); Assert.Equal(expected.ToInt(), test.ToInt()); Assert.Equal(expected.ToString(), test.ToString()); Assert.Equal(expected.ToBlob(), test.ToBlob()); }
private static object ToObject(this ISQLiteValue value, Type clrType) { // Just in case the clrType is nullable clrType = clrType.GetUnderlyingType(); if (value.SQLiteType == SQLiteType.Null) { return(null); } else if (clrType == typeof(String)) { return(value.ToString()); } else if (clrType == typeof(Int32)) { return(value.ToInt()); } else if (clrType == typeof(Boolean)) { return(value.ToBool()); } else if (clrType == typeof(double)) { return(value.ToDouble()); } else if (clrType == typeof(float)) { return(value.ToFloat()); } else if (clrType == typeof(TimeSpan)) { return(value.ToTimeSpan()); } else if (clrType == typeof(DateTime)) { return(value.ToDateTime()); } else if (clrType == typeof(DateTimeOffset)) { return(value.ToDateTimeOffset()); } else if (clrType.GetTypeInfo().IsEnum) { return(value.ToInt()); } else if (clrType == typeof(Int64)) { return(value.ToInt64()); } else if (clrType == typeof(UInt32)) { return(value.ToUInt32()); } else if (clrType == typeof(decimal)) { return(value.ToDecimal()); } else if (clrType == typeof(Byte)) { return(value.ToByte()); } else if (clrType == typeof(UInt16)) { return(value.ToUInt16()); } else if (clrType == typeof(Int16)) { return(value.ToShort()); } else if (clrType == typeof(sbyte)) { return(value.ToSByte()); } else if (clrType == typeof(byte[])) { return(value.ToBlob()); } else if (clrType == typeof(Guid)) { return(value.ToGuid()); } else if (clrType == typeof(Uri)) { return(value.ToUri()); } else { throw new NotSupportedException($"Don't know how to read {clrType}"); } }