/// <summary> /// Converts the value of the specified SqlInt32 to its equivalent SqlInt64 representation. /// </summary> /// <param name="value">An SqlInt32.</param> /// <returns>The equivalent SqlInt64.</returns> public static SqlInt64 ToSqlInt64(SqlInt32 value) { return value.ToSqlInt64(); }
public void ConversionMethods () { SqlInt32 x; // Case 1: SqlInt32.Null -> SqlBoolean == SqlBoolean.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlBoolean (), SqlBoolean.Null , "SqlInt32.Null -> SqlBoolean does not yield SqlBoolean.Null."); // Case 2: SqlInt32.Zero -> SqlBoolean == False x = SqlInt32.Zero; Assert.AreEqual (x.ToSqlBoolean (), SqlBoolean.False , "SqlInt32.Zero -> SqlBoolean does not yield SqlBoolean.False."); // Case 3: SqlInt32(nonzero) -> SqlBoolean == True x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlBoolean (), SqlBoolean.True , "SqlInt32 (27) -> SqlBoolean does not yield SqlBoolean.True."); // Case 4: SqlInt32.Null -> SqlByte == SqlByte.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlByte (), SqlByte.Null , "SqlInt32.Null -> SqlByte does not yield SqlByte.Null."); // Case 5: Test non-null conversion to SqlByte x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlByte ().Value, (byte)27, "SqlInt32 (27) -> SqlByte does not yield a value of 27"); // Case 6: SqlInt32.Null -> SqlDecimal == SqlDecimal.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlDecimal (), SqlDecimal.Null , "SqlInt32.Null -> SqlDecimal does not yield SqlDecimal.Null."); // Case 7: Test non-null conversion to SqlDecimal x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlDecimal ().Value, (decimal)27, "SqlInt32 (27) -> SqlDecimal does not yield a value of 27"); // Case 8: SqlInt32.Null -> SqlDouble == SqlDouble.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlDouble (), SqlDouble.Null , "SqlInt32.Null -> SqlDouble does not yield SqlDouble.Null."); // Case 9: Test non-null conversion to SqlDouble x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlDouble ().Value, (double)27, "SqlInt32 (27) -> SqlDouble does not yield a value of 27"); // Case 10: SqlInt32.Null -> SqlInt16 == SqlInt16.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlInt16 (), SqlInt16.Null , "SqlInt32.Null -> SqlInt16 does not yield SqlInt16.Null."); // Case 11: Test non-null conversion to SqlInt16 x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlInt16 ().Value, (short)27, "SqlInt32 (27) -> SqlInt16 does not yield a value of 27"); // Case 12: SqlInt32.Null -> SqlInt64 == SqlInt64.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlInt64 (), SqlInt64.Null , "SqlInt32.Null -> SqlInt64 does not yield SqlInt64.Null."); // Case 13: Test non-null conversion to SqlInt64 x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlInt64 ().Value, (long)27, "SqlInt32 (27) -> SqlInt64 does not yield a value of 27"); // Case 14: SqlInt32.Null -> SqlMoney == SqlMoney.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlMoney (), SqlMoney.Null , "SqlInt32.Null -> SqlMoney does not yield SqlMoney.Null."); // Case 15: Test non-null conversion to SqlMoney x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlMoney ().Value, 27.0000M, "SqlInt32 (27) -> SqlMoney does not yield a value of 27"); // Case 16: SqlInt32.Null -> SqlSingle == SqlSingle.Null x = SqlInt32.Null; Assert.AreEqual (x.ToSqlSingle (), SqlSingle.Null , "SqlInt32.Null -> SqlSingle does not yield SqlSingle.Null."); // Case 17: Test non-null conversion to SqlSingle x = new SqlInt32 (27); Assert.AreEqual (x.ToSqlSingle ().Value, (float)27, "SqlInt32 (27) -> SqlSingle does not yield a value of 27"); }
/// <summary>Converts the value from <c>SqlInt32</c> to an equivalent <c>SqlInt64</c> value.</summary> public static SqlInt64 ToSqlInt64(SqlInt32 p) { return p.ToSqlInt64(); }
public void ConversionMethods() { SqlInt32 x; // Case 1: SqlInt32.Null -> SqlBoolean == SqlBoolean.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlBoolean(), SqlBoolean.Null); // Case 2: SqlInt32.Zero -> SqlBoolean == False x = SqlInt32.Zero; Assert.Equal(x.ToSqlBoolean(), SqlBoolean.False); // Case 3: SqlInt32(nonzero) -> SqlBoolean == True x = new SqlInt32(27); Assert.Equal(x.ToSqlBoolean(), SqlBoolean.True); // Case 4: SqlInt32.Null -> SqlByte == SqlByte.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlByte(), SqlByte.Null); // Case 5: Test non-null conversion to SqlByte x = new SqlInt32(27); Assert.Equal(x.ToSqlByte().Value, (byte)27); // Case 6: SqlInt32.Null -> SqlDecimal == SqlDecimal.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlDecimal(), SqlDecimal.Null); // Case 7: Test non-null conversion to SqlDecimal x = new SqlInt32(27); Assert.Equal(x.ToSqlDecimal().Value, 27); // Case 8: SqlInt32.Null -> SqlDouble == SqlDouble.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlDouble(), SqlDouble.Null); // Case 9: Test non-null conversion to SqlDouble x = new SqlInt32(27); Assert.Equal(x.ToSqlDouble().Value, 27); // Case 10: SqlInt32.Null -> SqlInt16 == SqlInt16.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlInt16(), SqlInt16.Null); // Case 11: Test non-null conversion to SqlInt16 x = new SqlInt32(27); Assert.Equal(x.ToSqlInt16().Value, (short)27); // Case 12: SqlInt32.Null -> SqlInt64 == SqlInt64.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlInt64(), SqlInt64.Null); // Case 13: Test non-null conversion to SqlInt64 x = new SqlInt32(27); Assert.Equal(x.ToSqlInt64().Value, 27); // Case 14: SqlInt32.Null -> SqlMoney == SqlMoney.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlMoney(), SqlMoney.Null); // Case 15: Test non-null conversion to SqlMoney x = new SqlInt32(27); Assert.Equal(x.ToSqlMoney().Value, 27.0000M); // Case 16: SqlInt32.Null -> SqlSingle == SqlSingle.Null x = SqlInt32.Null; Assert.Equal(x.ToSqlSingle(), SqlSingle.Null); // Case 17: Test non-null conversion to SqlSingle x = new SqlInt32(27); Assert.Equal(x.ToSqlSingle().Value, 27); }