public static void BinaryTypeNotEqualToOtherType() { var type1 = new SqlBinaryType(SqlTypeCode.VarBinary); var type2 = new SqlBooleanType(SqlTypeCode.Bit); Assert.False(type1.Equals(type2)); }
public void BooleanTypesEqual(SqlTypeCode typeCode1, SqlTypeCode typeCode2, bool expected) { var type1 = new SqlBooleanType(typeCode1); var type2 = new SqlBooleanType(typeCode2); Assert.Equal(expected, type1.Equals(type2)); }
public void SerializeExplicit(SqlTypeCode typeCode) { var type = new SqlBooleanType(typeCode); var result = SqlTypeUtil.Serialize(type); Assert.Equal(type, result); }
public static void Multiply() { var a = SqlBoolean.True; var b = SqlBoolean.False; var type = new SqlBooleanType(SqlTypeCode.Boolean); var result = type.Multiply(a, b); Assert.IsType<SqlNull>(result); }
public void GetString(SqlTypeCode typeCode, string expected) { var type = new SqlBooleanType(typeCode); var s = type.ToString(); Assert.Equal(expected, s); }
public static void FalseToString() { var type = new SqlBooleanType(SqlTypeCode.Boolean); var value = SqlBoolean.False; var s = type.ToString(value); Assert.Equal("FALSE", s); }
public static void TrueToString() { var type = new SqlBooleanType(SqlTypeCode.Boolean); var value = SqlBoolean.True; var s = type.ToString(value); Assert.Equal("TRUE", s); }
public static void Negate(bool value, bool expected) { var b = (SqlBoolean) value; var type = new SqlBooleanType(SqlTypeCode.Boolean); var result = type.Negate(b); var exp = (SqlBoolean) expected; Assert.Equal(exp, result); }
public void Compare_Booleans() { var type = new SqlBooleanType(SqlTypeCode.Boolean); Assert.NotNull(type); Assert.Equal(1, type.Compare(SqlBoolean.True, SqlBoolean.False)); Assert.Equal(-1, type.Compare(SqlBoolean.False, SqlBoolean.True)); Assert.Equal(0, type.Compare(SqlBoolean.True, SqlBoolean.True)); Assert.Equal(0, type.Compare(SqlBoolean.False, SqlBoolean.False)); }
public static void NotEqual(bool a, bool b, bool expected) { var x = (SqlBoolean)a; var y = (SqlBoolean)b; var type = new SqlBooleanType(SqlTypeCode.Boolean); var result = type.NotEqual(x, y); var exp = (SqlBoolean)expected; Assert.Equal(exp, result); }
public static SqlType Deserialize(BinaryReader reader, ISqlTypeResolver typeResolver) { var typeCode = (SqlTypeCode)reader.ReadByte(); if (SqlBooleanType.IsBooleanType(typeCode)) { return(PrimitiveTypes.Boolean(typeCode)); } if (SqlDateTimeType.IsDateType(typeCode)) { return(PrimitiveTypes.DateTime(typeCode)); } if (typeCode == SqlTypeCode.DayToSecond) { return(PrimitiveTypes.DayToSecond()); } if (typeCode == SqlTypeCode.YearToMonth) { return(PrimitiveTypes.YearToMonth()); } if (SqlCharacterType.IsStringType(typeCode)) { var maxSize = reader.ReadInt32(); CultureInfo locale = null; var hasLocale = reader.ReadByte() == 1; if (hasLocale) { var name = reader.ReadString(); locale = new CultureInfo(name); } return(PrimitiveTypes.String(typeCode, maxSize, locale)); } if (SqlNumericType.IsNumericType(typeCode)) { var size = reader.ReadInt32(); var scale = reader.ReadInt32(); return(PrimitiveTypes.Numeric(typeCode, size, scale)); } if (SqlBinaryType.IsBinaryType(typeCode)) { var size = reader.ReadInt32(); return(PrimitiveTypes.Binary(typeCode, size)); } if (typeCode == SqlTypeCode.Type) { if (typeResolver == null) { throw new NotSupportedException("User-Defined types require a resolver context."); } // TODO: support type arguments var typeName = reader.ReadString(); return(typeResolver.Resolve(new SqlTypeResolveInfo(typeName))); } /* * TODO: * if (typeCode == SqlTypeCode.QueryPlan) * return new SqlQueryType(); */ if (typeCode == SqlTypeCode.Array) { var size = reader.ReadInt32(); return(new SqlArrayType(size)); } throw new NotSupportedException($"The type code '{typeCode}' does not support deserialization"); }