ToSqlInt16() public method

public ToSqlInt16 ( ) : SqlInt16
return SqlInt16
Esempio n. 1
0
		/// <summary>Converts the value from <c>SqlString</c> to an equivalent <c>SqlInt16</c> value.</summary>
		public static SqlInt16 ToSqlInt16(SqlString  p) { return p.ToSqlInt16();                                                                    }
Esempio n. 2
0
        // SqlTypes.

        /// <summary>
        /// Converts the value of the specified SqlString to its equivalent SqlInt16 representation.
        /// </summary>
        /// <param name="value">An SqlString.</param>
        /// <returns>The equivalent SqlInt16.</returns>
        public static SqlInt16 ToSqlInt16(SqlString value) { return value.ToSqlInt16(); }
Esempio n. 3
0
		public void Conversions()
		{
			SqlString String250 = new SqlString ("250");
			SqlString String9E300 = new SqlString ("9E+300");

			// ToSqlBoolean ()
			Assert.IsTrue ((new SqlString("1")).ToSqlBoolean ().Value, "#O02");
			Assert.IsTrue (!(new SqlString("0")).ToSqlBoolean ().Value, "#O03");
			Assert.IsTrue ((new SqlString("True")).ToSqlBoolean ().Value, "#O04");
			Assert.IsTrue (!(new SqlString("FALSE")).ToSqlBoolean ().Value, "#O05");
			Assert.IsTrue (SqlString.Null.ToSqlBoolean ().IsNull, "#O06");

			// ToSqlByte ()
			Assert.AreEqual ((byte)250, String250.ToSqlByte ().Value, "#O08");

			// ToSqlDateTime
			Assert.AreEqual (10, 
				(new SqlString ("2002-10-10")).ToSqlDateTime ().Value.Day, "#O11");

			// ToSqlDecimal ()
			Assert.AreEqual ((decimal)250, String250.ToSqlDecimal ().Value, "#O16");

			// ToSqlDouble
			Assert.AreEqual ((SqlDouble)9E+300, String9E300.ToSqlDouble (), "#O19");

			// ToSqlGuid
			SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
			Assert.AreEqual (new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid (), "#O22");

			// ToSqlInt16 ()
			Assert.AreEqual ((short)250, String250.ToSqlInt16 ().Value, "#O24");

			// ToSqlInt32 ()
			Assert.AreEqual ((int)250, String250.ToSqlInt32 ().Value, "#O27");

			// ToSqlInt64 ()
			Assert.AreEqual ((long)250, String250.ToSqlInt64 ().Value, "#O32");

			// ToSqlMoney ()
			Assert.AreEqual (250.0000M, String250.ToSqlMoney ().Value, "#O35");

			// ToSqlSingle ()
			Assert.AreEqual ((float)250, String250.ToSqlSingle ().Value, "#O38");

			// ToString ()
			Assert.AreEqual ("First TestString", Test1.ToString (), "#O41");
		}
Esempio n. 4
0
		public void ConversionInt16FormatException ()
		{
			SqlString String9E300 = new SqlString ("9E+300");
			SqlInt16 test = String9E300.ToSqlInt16().Value;
		}
Esempio n. 5
0
        public void Conversions()
        {
            SqlString String250 = new SqlString("250");
            SqlString String9E300 = new SqlString("9E+300");

            // ToSqlBoolean ()
            Assert.True((new SqlString("1")).ToSqlBoolean().Value);
            Assert.True(!(new SqlString("0")).ToSqlBoolean().Value);
            Assert.True((new SqlString("True")).ToSqlBoolean().Value);
            Assert.True(!(new SqlString("FALSE")).ToSqlBoolean().Value);
            Assert.True(SqlString.Null.ToSqlBoolean().IsNull);

            // ToSqlByte ()
            Assert.Equal((byte)250, String250.ToSqlByte().Value);

            // ToSqlDateTime
            Assert.Equal(10, (new SqlString("2002-10-10")).ToSqlDateTime().Value.Day);

            // ToSqlDecimal ()
            Assert.Equal(250, String250.ToSqlDecimal().Value);

            // ToSqlDouble
            Assert.Equal(9E+300, String9E300.ToSqlDouble());

            // ToSqlGuid
            SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
            Assert.Equal(new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid());

            // ToSqlInt16 ()
            Assert.Equal((short)250, String250.ToSqlInt16().Value);

            // ToSqlInt32 ()
            Assert.Equal(250, String250.ToSqlInt32().Value);

            // ToSqlInt64 ()
            Assert.Equal(250, String250.ToSqlInt64().Value);

            // ToSqlMoney ()
            Assert.Equal(250.0000M, String250.ToSqlMoney().Value);

            // ToSqlSingle ()
            Assert.Equal(250, String250.ToSqlSingle().Value);

            // ToString ()
            Assert.Equal("First TestString", _test1.ToString());
        }
Esempio n. 6
0
 public void ConversionInt16FormatException()
 {
     Assert.Throws<FormatException>(() =>
     {
         SqlString String9E300 = new SqlString("9E+300");
         SqlInt16 test = String9E300.ToSqlInt16().Value;
     });
 }
                public void Conversions()
                {

                        SqlString String250 = new SqlString ("250");
                        SqlString String9E300 = new SqlString ("9E+300");

                        // ToSqlBoolean ()                                
                        Assert ("#O02", (new SqlString("1")).ToSqlBoolean ().Value);
                        Assert ("#O03", !(new SqlString("0")).ToSqlBoolean ().Value);
                        Assert ("#O04", (new SqlString("True")).ToSqlBoolean ().Value);
                        Assert ("#O05", !(new SqlString("FALSE")).ToSqlBoolean ().Value);
                        Assert ("#O06", SqlString.Null.ToSqlBoolean ().IsNull);

                        // ToSqlByte ()
                        AssertEquals ("#O08", (byte)250, String250.ToSqlByte ().Value);    

                        // ToSqlDateTime
                        AssertEquals ("#O11", 10, 
                                      (new SqlString ("2002-10-10")).ToSqlDateTime ().Value.Day);
                        
                        // ToSqlDecimal ()
                        AssertEquals ("#O16", (decimal)250, String250.ToSqlDecimal ().Value);

                        // ToSqlDouble
                        AssertEquals ("#O19", (SqlDouble)9E+300, String9E300.ToSqlDouble ());

                        // ToSqlGuid
                        SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
                        AssertEquals ("#O22", new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid ());

                        // ToSqlInt16 ()
                        AssertEquals ("#O24", (short)250, String250.ToSqlInt16 ().Value);

                        // ToSqlInt32 ()
                        AssertEquals ("#O27", (int)250, String250.ToSqlInt32 ().Value);

                        // ToSqlInt64 ()
                        AssertEquals ("#O32", (long)250, String250.ToSqlInt64 ().Value);

                        // ToSqlMoney ()
                        AssertEquals ("#O35", 250.0000M, String250.ToSqlMoney ().Value);


                        // ToSqlSingle ()
                        AssertEquals ("#O38", (float)250, String250.ToSqlSingle ().Value);

                        // ToString ()
                        AssertEquals ("#O41", "First TestString", Test1.ToString ());
                }