Exemplo n.º 1
0
        public void TestNullValueForLong()
        {
            // get map to make sure object map is ok
            ObjectMap om = ObjectFactory.GetMap(null, typeof(BigNull));
            FieldMap  fm = om.GetFieldMap("bigNull");

            Assert.IsTrue(fm.NullValue != null, "NullValue not set.");
            Assert.IsTrue(fm.IsNullable, "Database column not marked as nullable.");
            Assert.IsTrue(fm.IsValueType, "Type not a value type (can hold null).");
            Assert.IsFalse(fm.IsNullAssignable, "Type can hold null.");
            long x = 0;

            Assert.AreEqual(x, fm.NullValue, "Comparison 1 of object and long failed.");
            Assert.IsTrue(x.Equals(fm.NullValue), "Comparison 2 of object and long failed.");
            Assert.IsTrue(fm.NullValue.Equals(x), "Comparison 3 of object and long failed.");
            // create test statement with bigint parameter
            SqlBuilder   sb   = new SqlBuilder(StatementType.Insert, typeof(BigNull));
            SqlStatement stmt = sb.GetStatement();
            // create object and set statement params
            BigNull bn = new BigNull();

            stmt.SetParameters(bn, true);
            // verify parameter values (assume bigNull is first and only param)
            IDbDataParameter param = stmt.Command.Parameters[0] as IDbDataParameter;

            Assert.AreEqual(DBNull.Value, param.Value, "Parameter 0 not converted to DBNull.");
        }
Exemplo n.º 2
0
		public void TestNullValueForLong()
		{
			// get map to make sure object map is ok
			ObjectMap om = ObjectFactory.GetMap( null, typeof(BigNull) );
			FieldMap fm = om.GetFieldMap( "bigNull" );
			Assert.IsTrue( fm.NullValue != null, "NullValue not set." );
			Assert.IsTrue( fm.IsNullable, "Database column not marked as nullable." );
			Assert.IsTrue( fm.IsValueType, "Type not a value type (can hold null)." );
			Assert.IsFalse( fm.IsNullAssignable, "Type can hold null." );
			long x = 0;
			Assert.AreEqual( x, fm.NullValue, "Comparison 1 of object and long failed." );
			Assert.IsTrue( x.Equals( fm.NullValue ), "Comparison 2 of object and long failed." );
			Assert.IsTrue( fm.NullValue.Equals( x ), "Comparison 3 of object and long failed." );
			// create test statement with bigint parameter
			SqlBuilder sb = new SqlBuilder( StatementType.Insert, typeof(BigNull) );
			SqlStatement stmt = sb.GetStatement();
			// create object and set statement params
			BigNull bn = new BigNull();
			stmt.SetParameters( bn, true );
			// verify parameter values (assume bigNull is first and only param)
			IDbDataParameter param = stmt.Command.Parameters[ 0 ] as IDbDataParameter;
			Assert.AreEqual( DBNull.Value, param.Value, "Parameter 0 not converted to DBNull." );
		}