| | | 1 | | using ValidateLib.ErrorsAndWarnings.Errors.Specific; |
| | | 2 | | using ValidateLib.Metadata.Descriptors; |
| | | 3 | | using ValidateLib.TabularData.Datatypes; |
| | | 4 | | |
| | | 5 | | namespace DatatypeTests |
| | | 6 | | { |
| | | 7 | | public class DateTimeStampTests |
| | | 8 | | { |
| | | 9 | | [Theory] |
| | | 10 | | [InlineData("2015-03-15T15:02:37Z", "yyyy-MM-ddTHH:mm:ssXXX")] |
| | | 11 | | [InlineData("2015-03-15T15:02:37-05:00", "yyyy-MM-ddTHH:mm:ssXXX")] |
| | | 12 | | |
| | | 13 | | public void DateTimeSupportedPatternsTests(string stringValue, string formatPattern) |
| | 1 | 14 | | { |
| | 1 | 15 | | FormatDescriptor format = new FormatDescriptor { pattern = formatPattern }; |
| | 1 | 16 | | DatatypeFactory.GetDatatype(stringValue, "dateTimeStamp", format); |
| | 1 | 17 | | } |
| | | 18 | | |
| | | 19 | | [Theory] |
| | | 20 | | [InlineData("2015-03-15T15:02:37.143", "yyyy-MM-ddTHH:mm:ss.SSS")] |
| | | 21 | | [InlineData("2015-03-15T15:02:37.14356", "yyyy-MM-ddTHH:mm:ss.SSSSS")] |
| | | 22 | | [InlineData("2015-03-15T15:02:37", "yyyy-MM-ddTHH:mm:ss")] |
| | | 23 | | [InlineData("2015-03-15T15:02", "yyyy-MM-ddTHH:mm")] |
| | | 24 | | [InlineData("3/22/2015 15:02", "M/d/yyyy HH:mm")] |
| | | 25 | | [InlineData("22.03.2015 15:02:37", "dd.MM.yyyy HH:mm:ss")] |
| | | 26 | | |
| | | 27 | | public void DateTimeNotSupportedPatternsTests(string stringValue, string formatPattern) |
| | 1 | 28 | | { |
| | 1 | 29 | | FormatDescriptor format = new FormatDescriptor { pattern = formatPattern }; |
| | 1 | 30 | | Assert.Throws<InvalidFormatError>(() => DatatypeFactory.GetDatatype(stringValue, "dateTimeStamp", format)); |
| | 1 | 31 | | } |
| | | 32 | | |
| | | 33 | | [Theory] |
| | | 34 | | [InlineData("2015-03-15T15:02:37+00:00")] |
| | | 35 | | [InlineData("2015-03-15T15:02:14Z")] |
| | | 36 | | [InlineData("2015-03-15T15:02:37-05:00")] |
| | | 37 | | |
| | | 38 | | public void DateTimeValidDatesWithoutFormatTests(string stringValue) |
| | 1 | 39 | | { |
| | 1 | 40 | | FormatDescriptor format = new FormatDescriptor { }; |
| | 1 | 41 | | DatatypeFactory.GetDatatype(stringValue, "dateTimeStamp", format); |
| | 1 | 42 | | } |
| | | 43 | | |
| | | 44 | | [Theory] |
| | | 45 | | [InlineData("2015-03-15T15:02:14")] |
| | | 46 | | [InlineData("03-04-1999T15:02:14")] |
| | | 47 | | |
| | | 48 | | public void DateTimeInvalidDatesWithoutFormatTests(string stringValue) |
| | 1 | 49 | | { |
| | 1 | 50 | | FormatDescriptor format = new FormatDescriptor { }; |
| | 1 | 51 | | Assert.Throws<DatatypeValidationError>(() => DatatypeFactory.GetDatatype(stringValue, "dateTimeStamp", forma |
| | 1 | 52 | | } |
| | | 53 | | |
| | | 54 | | [Theory] |
| | | 55 | | [InlineData("2015-03-15T15:02:37", "yyyy-MM-ddTHH:mm:ss.SSS")] |
| | | 56 | | [InlineData("2015-03-15T15:02:37.143", "yyyy-MM-ddTHH:mm:ss.SSSSS")] |
| | | 57 | | [InlineData("2015-03-15T15", "yyyy-MM-ddTHH:mm:ss")] |
| | | 58 | | [InlineData("15-03-2032T15:02", "yyyy-MM-ddTHH:mm")] |
| | | 59 | | [InlineData("3/22/2015 15:02+05:00", "M/d/yyyy HH:mm")] |
| | | 60 | | [InlineData("22.03.2015 15:02:37Z", "dd.MM.yyyy HH:mm:ss")] |
| | | 61 | | [InlineData("2015-03-15T15:02:37", "yyyy-MM-ddTHH:mm:ssXXX")] |
| | | 62 | | [InlineData("2015-03T15:02:37-05:00", "yyyy-MM-ddTHH:mm:ssXXX")] |
| | | 63 | | |
| | | 64 | | public void DateTimeInvalidValuesWithPatternTests(string stringValue, string formatPattern) |
| | 1 | 65 | | { |
| | 1 | 66 | | FormatDescriptor format = new FormatDescriptor { pattern = formatPattern }; |
| | 1 | 67 | | Assert.Throws<DatatypeValidationError>(() => DatatypeFactory.GetDatatype(stringValue, "dateTimeStamp", forma |
| | 1 | 68 | | } |
| | | 69 | | |
| | | 70 | | } |
| | | 71 | | } |