|
| 1 | +using System; |
| 2 | +using System.Data; |
| 3 | +using AdoNet.Specification.Tests; |
| 4 | + |
| 5 | +namespace Conformance.Tests |
| 6 | +{ |
| 7 | + public class GetValueConversionTests : GetValueConversionTestBase<SelectValueFixture> |
| 8 | + { |
| 9 | + public GetValueConversionTests(SelectValueFixture fixture) |
| 10 | + : base(fixture) |
| 11 | + { |
| 12 | + } |
| 13 | + |
| 14 | + // GetBoolean allows conversions from any integral type for backwards compatibility |
| 15 | + public override void GetBoolean_throws_for_maximum_Byte() => TestGetValue(DbType.Byte, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 16 | + public override void GetBoolean_throws_for_maximum_Int16() => TestGetValue(DbType.Int16, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 17 | + public override void GetBoolean_throws_for_maximum_Int32() => TestGetValue(DbType.Int32, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 18 | + public override void GetBoolean_throws_for_maximum_Int64() => TestGetValue(DbType.Int64, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 19 | + public override void GetBoolean_throws_for_maximum_SByte() => TestGetValue(DbType.SByte, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 20 | + public override void GetBoolean_throws_for_maximum_UInt16() => TestGetValue(DbType.UInt16, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 21 | + public override void GetBoolean_throws_for_maximum_UInt32() => TestGetValue(DbType.UInt32, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 22 | + public override void GetBoolean_throws_for_maximum_UInt64() => TestGetValue(DbType.UInt64, ValueKind.Maximum, x => x.GetBoolean(0), true); |
| 23 | + public override void GetBoolean_throws_for_minimum_Byte() => TestGetValue(DbType.Byte, ValueKind.Minimum, x => x.GetBoolean(0), false); |
| 24 | + public override void GetBoolean_throws_for_minimum_Int16() => TestGetValue(DbType.Int16, ValueKind.Minimum, x => x.GetBoolean(0), true); |
| 25 | + public override void GetBoolean_throws_for_minimum_Int32() => TestGetValue(DbType.Int32, ValueKind.Minimum, x => x.GetBoolean(0), true); |
| 26 | + public override void GetBoolean_throws_for_minimum_Int64() => TestGetValue(DbType.Int64, ValueKind.Minimum, x => x.GetBoolean(0), true); |
| 27 | + public override void GetBoolean_throws_for_minimum_SByte() => TestGetValue(DbType.SByte, ValueKind.Minimum, x => x.GetBoolean(0), true); |
| 28 | + public override void GetBoolean_throws_for_minimum_UInt16() => TestGetValue(DbType.UInt16, ValueKind.Minimum, x => x.GetBoolean(0), false); |
| 29 | + public override void GetBoolean_throws_for_minimum_UInt32() => TestGetValue(DbType.UInt32, ValueKind.Minimum, x => x.GetBoolean(0), false); |
| 30 | + public override void GetBoolean_throws_for_minimum_UInt64() => TestGetValue(DbType.UInt64, ValueKind.Minimum, x => x.GetBoolean(0), false); |
| 31 | + public override void GetBoolean_throws_for_one_Byte() => TestGetValue(DbType.Byte, ValueKind.One, x => x.GetBoolean(0), true); |
| 32 | + public override void GetBoolean_throws_for_one_Int16() => TestGetValue(DbType.Int16, ValueKind.One, x => x.GetBoolean(0), true); |
| 33 | + public override void GetBoolean_throws_for_one_Int32() => TestGetValue(DbType.Int32, ValueKind.One, x => x.GetBoolean(0), true); |
| 34 | + public override void GetBoolean_throws_for_one_Int64() => TestGetValue(DbType.Int64, ValueKind.One, x => x.GetBoolean(0), true); |
| 35 | + public override void GetBoolean_throws_for_one_SByte() => TestGetValue(DbType.SByte, ValueKind.One, x => x.GetBoolean(0), true); |
| 36 | + public override void GetBoolean_throws_for_one_UInt16() => TestGetValue(DbType.UInt16, ValueKind.One, x => x.GetBoolean(0), true); |
| 37 | + public override void GetBoolean_throws_for_one_UInt32() => TestGetValue(DbType.UInt32, ValueKind.One, x => x.GetBoolean(0), true); |
| 38 | + public override void GetBoolean_throws_for_one_UInt64() => TestGetValue(DbType.UInt64, ValueKind.One, x => x.GetBoolean(0), true); |
| 39 | + public override void GetBoolean_throws_for_zero_Byte() => TestGetValue(DbType.Byte, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 40 | + public override void GetBoolean_throws_for_zero_Int16() => TestGetValue(DbType.Int16, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 41 | + public override void GetBoolean_throws_for_zero_Int32() => TestGetValue(DbType.Int32, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 42 | + public override void GetBoolean_throws_for_zero_Int64() => TestGetValue(DbType.Int64, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 43 | + public override void GetBoolean_throws_for_zero_SByte() => TestGetValue(DbType.SByte, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 44 | + public override void GetBoolean_throws_for_zero_UInt16() => TestGetValue(DbType.UInt16, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 45 | + public override void GetBoolean_throws_for_zero_UInt32() => TestGetValue(DbType.UInt32, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 46 | + public override void GetBoolean_throws_for_zero_UInt64() => TestGetValue(DbType.UInt64, ValueKind.Zero, x => x.GetBoolean(0), false); |
| 47 | + |
| 48 | + // the minimum date permitted by MySQL is 1000-01-01; override the minimum value for DateTime tests |
| 49 | + public override void GetDateTime_for_minimum_Date() => TestGetValue(DbType.Date, ValueKind.Minimum, x => x.GetDateTime(0), new DateTime(1000, 1, 1)); |
| 50 | + public override void GetDateTime_for_minimum_DateTime() => TestGetValue(DbType.Date, ValueKind.Minimum, x => x.GetDateTime(0), new DateTime(1000, 1, 1)); |
| 51 | + } |
| 52 | +} |
0 commit comments