< Summary

Information
Class: ValidateLib.TabularData.Datatypes.BaseDT
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\TabularData\Datatypes\BaseDT.cs
Line coverage
60%
Covered lines: 17
Uncovered lines: 11
Coverable lines: 28
Total lines: 63
Line coverage: 60.7%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\TabularData\Datatypes\BaseDT.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2using ValidateLib.ErrorsAndWarnings.Errors;
 3using ValidateLib.Metadata.Descriptors;
 4
 5namespace ValidateLib.TabularData.Datatypes
 6{
 7    public class BaseDT : IComparable<BaseDT>
 8    {
 19        public string stringValue { get; set; }
 110        public FormatDescriptor? format { get; set; }
 11
 112        public BaseDT()
 13        {
 114            stringValue = "Invalid";
 115        }
 116        public BaseDT(string stringValue)
 17        {
 118            this.stringValue = stringValue;
 119        }
 20
 121        public BaseDT(string stringValue, FormatDescriptor format)
 22        {
 123            this.stringValue = stringValue;
 124            this.format = format;
 125        }
 26
 27        protected void MatchRegex(string regexString, string stringValue)
 28        {
 29            try
 30            {
 131                Regex regex = new Regex(regexString);
 132                if (!regex.IsMatch(stringValue))
 133                    ErrorFactory.ThrowDatatypeValidationError($"regex: {regexString} value: {stringValue}");
 134            }
 035            catch (ArgumentException)
 36            {
 037                ErrorFactory.ThrowDatatypeValidationError($"regex: {regexString} value: {stringValue}");
 038            }
 139        }
 40
 41        protected void VerifyFormatPatternIsValidRegex(string formatPattern)
 42        {
 43            try
 44            {
 045                Regex regex = new Regex(formatPattern);
 046            }
 047            catch (Exception)
 48            {
 049                ErrorFactory.ThrowInvalidFormatError(formatPattern, formatPattern);
 050            }
 051        }
 52
 53        virtual public int CompareTo(BaseDT? other)
 54        {
 055            throw new ArgumentException();
 56        }
 57
 58        virtual public bool IsPatternValid(FormatDescriptor format)
 59        {
 060            throw new NotImplementedException();
 61        }
 62    }
 63}