Пример #1
0
        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);
        }
Пример #8
0
        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());
 }