| | 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 IntegerTests |
| | 8 | | { |
| | 9 | |
|
| | 10 | |
|
| | 11 | | [Theory] |
| | 12 | | [InlineData("122")] |
| | 13 | | [InlineData("00122")] |
| | 14 | | [InlineData("0")] |
| | 15 | | [InlineData("+3")] |
| | 16 | | [InlineData("-3")] |
| | 17 | | public void ValidIntegerlnWithoutPatternTest(string stringValue) |
| 1 | 18 | | { |
| 1 | 19 | | IntegerDT integer = new IntegerDT(stringValue); |
| 1 | 20 | | } |
| | 21 | |
|
| | 22 | | [Theory] |
| | 23 | | [InlineData("not a decimal")] |
| | 24 | | [InlineData("3,5")] |
| | 25 | | [InlineData("3.")] |
| | 26 | | [InlineData("3.0")] |
| | 27 | | [InlineData(".3")] |
| | 28 | |
|
| | 29 | | public void IntegerWithoutPatternInvalidValues(string stringValue) |
| 1 | 30 | | { |
| 1 | 31 | | Assert.Throws<DatatypeValidationError>(() => new IntegerDT(stringValue)); |
| 1 | 32 | | } |
| | 33 | |
|
| | 34 | | [Theory] |
| | 35 | | [InlineData("10000.50", ",", null)] |
| | 36 | | [InlineData("10000.50", ",", ".")] |
| | 37 | | //integer cant contain decimal char |
| | 38 | | public void IntegerWithFormatWithoutPatternInValidValues(string stringValue, string? groupChar, string? decimalC |
| 1 | 39 | | { |
| 1 | 40 | | FormatDescriptor format = new FormatDescriptor |
| 1 | 41 | | { |
| 1 | 42 | | groupChar = groupChar, |
| 1 | 43 | | decimalChar = decimalChar, |
| 1 | 44 | | }; |
| | 45 | |
|
| 1 | 46 | | Assert.Throws<DatatypeValidationError>(() => new IntegerDT(stringValue, format)); |
| | 47 | |
|
| 1 | 48 | | } |
| | 49 | | [Theory] |
| | 50 | | [InlineData("+10;00;00", ";", null)] |
| | 51 | | [InlineData("+10,000,000", ",", null)] |
| | 52 | |
|
| | 53 | | public void IntegerWithFormatWithoutPatternValidValues(string stringValue, string? groupChar, string? decimalCha |
| 1 | 54 | | { |
| 1 | 55 | | FormatDescriptor format = new FormatDescriptor |
| 1 | 56 | | { |
| 1 | 57 | | groupChar = groupChar, |
| 1 | 58 | | decimalChar = decimalChar, |
| 1 | 59 | | }; |
| | 60 | |
|
| 1 | 61 | | var integerdt = new IntegerDT(stringValue, format); |
| 1 | 62 | | } |
| | 63 | | } |
| | 64 | | } |