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])); }
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()); }
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); }
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 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))); }
public void CreateParamFromValue() { Assert.Throws <TypeCannotBeUsedAsAClrTypeException>(() => SqlSmallDateTime.GetTypeHandler().CreateParamFromValue("Test", null)); }
public void GetTypeHandler() { Assert.IsInstanceOf <SqlTypeHandler>(SqlSmallDateTime.GetTypeHandler()); }