< Summary

Information
Class: DatatypeTests.DecimalTests
Assembly: datatypetests.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\Tests\DatatypeTests\Numeric\DecimalTests.cs
Line coverage
100%
Covered lines: 22
Uncovered lines: 0
Coverable lines: 22
Total lines: 88
Line coverage: 100%
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\Tests\DatatypeTests\Numeric\DecimalTests.cs

#LineLine coverage
 1using ValidateLib.ErrorsAndWarnings.Errors.Specific;
 2using ValidateLib.Metadata.Descriptors;
 3using ValidateLib.TabularData.Datatypes.NumericDatatypes;
 4
 5namespace DatatypeTests
 6{
 7    public class DecimalTests
 8    {
 9
 10
 11        [Theory]
 12        [InlineData("3.0")]
 13        [InlineData("-3.0")]
 14        [InlineData("+3.5")]
 15        [InlineData("3")]
 16        [InlineData(".3")]
 17        [InlineData("3.")]
 18        [InlineData("0")]
 19        [InlineData("-.3")]
 20        [InlineData("0003.0")]
 21        [InlineData("3.0000")]
 22        public void ValidDecimalnWithoutPatternTest(string stringValue)
 123        {
 124            DecimalDT dec = new DecimalDT(stringValue);
 125        }
 26
 27        [Theory]
 28        [InlineData("not a decimal")]
 29        [InlineData("3,5")]
 30        [InlineData("")]
 31
 32        public void DecimalWithoutPatternInvalidValues(string stringValue)
 133        {
 134            Assert.Throws<DatatypeValidationError>(() => new DecimalDT(stringValue));
 135        }
 36        [Theory]
 37        [InlineData("+10", ",", ".")]
 38        [InlineData("+10,000,000", ",", ".")]
 39        [InlineData("+10.5", ",", ".")]
 40        [InlineData("-10%", ",", ".")]
 41        [InlineData("-10‰", ",", ".")]
 42
 43        [InlineData("+10", null, ".")]
 44        [InlineData("+10.5", null, ".")]
 45        [InlineData("-10%", null, ".")]
 46        [InlineData("-10‰", null, ".")]
 47
 48        public void DecimalWithFormatWithoutPatternValidValues(string stringValue,string? groupChar,string? decimalChar)
 149        {
 150            FormatDescriptor format = new FormatDescriptor
 151            {
 152                groupChar = groupChar,
 153                decimalChar = decimalChar,
 154            };
 55
 156            var decimaldt = new DecimalDT(stringValue, format);
 157        }
 58
 59        [Theory]
 60        [InlineData("not decimal", ",", ".")]
 61        [InlineData("+10,000,000E4", ",", ".")]
 62        [InlineData("+10.5E-3", ",", ".")]
 63        [InlineData("-10%E+4", ",", ".")]
 64        [InlineData("10,,00", ",", ".")]
 65
 66        [InlineData("not decimal", null, ".")]
 67        [InlineData("+10.5E6", null, ".")]
 68        [InlineData("-10E+6", null, ".")]
 69        [InlineData("-10E-6", null, ".")]
 70
 71        [InlineData("NaN", null, ".")]
 72        [InlineData("INF", null, ".")]
 73        [InlineData("-INF", null, ".")]
 74
 75
 76        public void DecimalWithFormatWithoutPatternInValidValues(string stringValue, string? groupChar, string? decimalC
 177        {
 178            FormatDescriptor format = new FormatDescriptor
 179            {
 180                groupChar = groupChar,
 181                decimalChar = decimalChar,
 182            };
 83
 184            Assert.Throws<DatatypeValidationError>(()=> new DecimalDT(stringValue, format));
 185        }
 86
 87    }
 88}