public void Length()
        {
            var type = new SqlSmallDateTime(CompressionContext.NoCompression);

            Assert.Throws <ArgumentException>(() => type.GetValue(new byte[3]));
            Assert.Throws <ArgumentException>(() => type.GetValue(new byte[5]));
        }
示例#2
0
        public void GetRawValue()
        {
            SqlType type = new SqlSmallDateTime(testSmallDateTime, ParameterDirection.Input);
            Assert.AreEqual(testSmallDateTime, type.GetRawValue());

            type = new SqlSmallDateTime(null, ParameterDirection.Input);
            Assert.Null(type.GetRawValue());
        }
示例#3
0
        public void GetParameter()
        {
            SqlType type = new SqlSmallDateTime(testSmallDateTime, ParameterDirection.Input);
            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.SmallDateTime, testSmallDateTime);

            type = new SqlSmallDateTime(null, ParameterDirection.Input);
            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.SmallDateTime, DBNull.Value);
        }
示例#4
0
        public void GetRawValue()
        {
            SqlType type = new SqlSmallDateTime(testSmallDateTime, ParameterDirection.Input);

            Assert.AreEqual(testSmallDateTime, type.GetRawValue());

            type = new SqlSmallDateTime(null, ParameterDirection.Input);
            Assert.Null(type.GetRawValue());
        }
示例#5
0
        public void GetParameter()
        {
            SqlType type = new SqlSmallDateTime(testSmallDateTime, ParameterDirection.Input);

            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.SmallDateTime, testSmallDateTime);

            type = new SqlSmallDateTime(null, ParameterDirection.Input);
            TestHelper.AssertSqlParameter(type.GetParameter(), SqlDbType.SmallDateTime, DBNull.Value);
        }
示例#6
0
        public void CreateMetaData()
        {
            Assert.Throws<TypeCannotBeUsedAsAClrTypeException>(() => SqlSmallDateTime.GetTypeHandler().CreateMetaData(null));

            SqlTypeHandler col = new SqlSmallDateTime(testSmallDateTime, ParameterDirection.Input);
            var meta = col.CreateMetaData("Test");
            Assert.AreEqual(SqlDbType.SmallDateTime, meta.SqlDbType);
            Assert.AreEqual("Test", meta.Name);
        }
示例#7
0
        public void CreateMetaData()
        {
            Assert.Throws <TypeCannotBeUsedAsAClrTypeException>(() => SqlSmallDateTime.GetTypeHandler().CreateMetaData(null));

            SqlTypeHandler col  = new SqlSmallDateTime(testSmallDateTime, ParameterDirection.Input);
            var            meta = col.CreateMetaData("Test");

            Assert.AreEqual(SqlDbType.SmallDateTime, meta.SqlDbType);
            Assert.AreEqual("Test", meta.Name);
        }
        public void GetValue()
        {
            var type = new SqlSmallDateTime(CompressionContext.NoCompression);

            var input = new byte[] { 0xab, 0x02, 0x5d, 0x26 };

            Assert.AreEqual(new DateTime(1926, 11, 22, 11, 23, 0), Convert.ToDateTime(type.GetValue(input)));

            input = new byte[] { 0x49, 0x03, 0x99, 0x09 };
            Assert.AreEqual(new DateTime(1906, 9, 24, 14, 1, 0), Convert.ToDateTime(type.GetValue(input)));
        }
示例#9
0
 public void CreateParamFromValue()
 {
     Assert.Throws <TypeCannotBeUsedAsAClrTypeException>(() => SqlSmallDateTime.GetTypeHandler().CreateParamFromValue("Test", null));
 }
示例#10
0
 public void GetTypeHandler()
 {
     Assert.IsInstanceOf <SqlTypeHandler>(SqlSmallDateTime.GetTypeHandler());
 }