| | | 1 | | using ValidateLib.ErrorsAndWarnings.Errors.Specific; |
| | | 2 | | using ValidateLib.Metadata.Descriptors; |
| | | 3 | | using ValidateLib.TabularData.Datatypes.NumericDatatypes; |
| | | 4 | | |
| | | 5 | | namespace DatatypeTests |
| | | 6 | | { |
| | | 7 | | public class ShortTests |
| | | 8 | | { |
| | | 9 | | |
| | | 10 | | |
| | | 11 | | [Theory] |
| | | 12 | | [InlineData("+122")] |
| | | 13 | | [InlineData("32767")] |
| | | 14 | | [InlineData("-32768")] |
| | | 15 | | [InlineData("0")] |
| | | 16 | | [InlineData("-1231")] |
| | | 17 | | public void ValidShortWithoutPatternTest(string stringValue) |
| | 1 | 18 | | { |
| | 1 | 19 | | ShortDT shortdt = new ShortDT(stringValue); |
| | 1 | 20 | | } |
| | | 21 | | |
| | | 22 | | [Theory] |
| | | 23 | | [InlineData("not a decimal")] |
| | | 24 | | [InlineData("32768")] |
| | | 25 | | [InlineData("-32769")] |
| | | 26 | | [InlineData("3.0")] |
| | | 27 | | [InlineData("")] |
| | | 28 | | |
| | | 29 | | public void ShortWithoutPatternInvalidValues(string stringValue) |
| | 1 | 30 | | { |
| | 1 | 31 | | Assert.Throws<DatatypeValidationError>(() => new ShortDT(stringValue)); |
| | 1 | 32 | | } |
| | | 33 | | [Theory] |
| | | 34 | | [InlineData("+1;0;0", ";", null)] |
| | | 35 | | [InlineData("+1,0,0", ",", null)] |
| | | 36 | | |
| | | 37 | | public void ShortWithFormatWithoutPatternValidValues(string stringValue, string? groupChar, string? decimalChar) |
| | 1 | 38 | | { |
| | 1 | 39 | | FormatDescriptor format = new FormatDescriptor |
| | 1 | 40 | | { |
| | 1 | 41 | | groupChar = groupChar, |
| | 1 | 42 | | decimalChar = decimalChar, |
| | 1 | 43 | | }; |
| | | 44 | | |
| | 1 | 45 | | var shortdt = new ShortDT(stringValue, format); |
| | 1 | 46 | | } |
| | | 47 | | } |
| | | 48 | | } |