|
| 1 | +{* Licensed to the Apache Software Foundation (ASF) under one |
| 2 | + * or more contributor license agreements. See the NOTICE file |
| 3 | + * distributed with this work for additional information |
| 4 | + * regarding copyright ownership. The ASF licenses this file |
| 5 | + * to you under the Apache License, Version 2.0 (the |
| 6 | + * "License"); you may not use this file except in compliance |
| 7 | + * with the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, |
| 12 | + * software distributed under the License is distributed on an |
| 13 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | + * KIND, either express or implied. See the License for the |
| 15 | + * specific language governing permissions and limitations |
| 16 | + * under the License.} |
| 17 | + |
| 18 | +unit intf.ZUGFeRDTaxTypes.UnitTests; |
| 19 | + |
| 20 | +interface |
| 21 | + |
| 22 | +uses |
| 23 | + DUnitX.TestFramework, intf.ZUGFeRDTaxTypes; |
| 24 | + |
| 25 | +type |
| 26 | + [TestFixture] |
| 27 | + TZUGFeRDTaxTypesTest = class |
| 28 | + public |
| 29 | + [Test] |
| 30 | + procedure TestFromString; |
| 31 | + [Test] |
| 32 | + procedure TestEnumToString; |
| 33 | + end; |
| 34 | + |
| 35 | +implementation |
| 36 | + |
| 37 | +procedure TZUGFeRDTaxTypesTest.TestFromString; |
| 38 | +begin |
| 39 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAA, TZUGFeRDTaxTypesExtensions.FromString('AAA')); |
| 40 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAB, TZUGFeRDTaxTypesExtensions.FromString('AAB')); |
| 41 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAC, TZUGFeRDTaxTypesExtensions.FromString('AAC')); |
| 42 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAD, TZUGFeRDTaxTypesExtensions.FromString('AAD')); |
| 43 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAE, TZUGFeRDTaxTypesExtensions.FromString('AAE')); |
| 44 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAF, TZUGFeRDTaxTypesExtensions.FromString('AAF')); |
| 45 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAG, TZUGFeRDTaxTypesExtensions.FromString('AAG')); |
| 46 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAH, TZUGFeRDTaxTypesExtensions.FromString('AAH')); |
| 47 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAI, TZUGFeRDTaxTypesExtensions.FromString('AAI')); |
| 48 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAJ, TZUGFeRDTaxTypesExtensions.FromString('AAJ')); |
| 49 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAK, TZUGFeRDTaxTypesExtensions.FromString('AAK')); |
| 50 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAL, TZUGFeRDTaxTypesExtensions.FromString('AAL')); |
| 51 | + Assert.AreEqual(TZUGFeRDTaxTypes.AAM, TZUGFeRDTaxTypesExtensions.FromString('AAM')); |
| 52 | + Assert.AreEqual(TZUGFeRDTaxTypes.ADD, TZUGFeRDTaxTypesExtensions.FromString('ADD')); |
| 53 | + Assert.AreEqual(TZUGFeRDTaxTypes.BOL, TZUGFeRDTaxTypesExtensions.FromString('BOL')); |
| 54 | + Assert.AreEqual(TZUGFeRDTaxTypes.CAP, TZUGFeRDTaxTypesExtensions.FromString('CAP')); |
| 55 | + Assert.AreEqual(TZUGFeRDTaxTypes.CAR, TZUGFeRDTaxTypesExtensions.FromString('CAR')); |
| 56 | + Assert.AreEqual(TZUGFeRDTaxTypes.COC, TZUGFeRDTaxTypesExtensions.FromString('COC')); |
| 57 | + Assert.AreEqual(TZUGFeRDTaxTypes.CST, TZUGFeRDTaxTypesExtensions.FromString('CST')); |
| 58 | + Assert.AreEqual(TZUGFeRDTaxTypes.CUD, TZUGFeRDTaxTypesExtensions.FromString('CUD')); |
| 59 | + Assert.AreEqual(TZUGFeRDTaxTypes.CVD, TZUGFeRDTaxTypesExtensions.FromString('CVD')); |
| 60 | + Assert.AreEqual(TZUGFeRDTaxTypes.ENV, TZUGFeRDTaxTypesExtensions.FromString('ENV')); |
| 61 | + Assert.AreEqual(TZUGFeRDTaxTypes.EXC, TZUGFeRDTaxTypesExtensions.FromString('EXC')); |
| 62 | + Assert.AreEqual(TZUGFeRDTaxTypes.EXP, TZUGFeRDTaxTypesExtensions.FromString('EXP')); |
| 63 | + Assert.AreEqual(TZUGFeRDTaxTypes.FET, TZUGFeRDTaxTypesExtensions.FromString('FET')); |
| 64 | + Assert.AreEqual(TZUGFeRDTaxTypes.FRE, TZUGFeRDTaxTypesExtensions.FromString('FRE')); |
| 65 | + Assert.AreEqual(TZUGFeRDTaxTypes.GCN, TZUGFeRDTaxTypesExtensions.FromString('GCN')); |
| 66 | + Assert.AreEqual(TZUGFeRDTaxTypes.GST, TZUGFeRDTaxTypesExtensions.FromString('GST')); |
| 67 | + Assert.AreEqual(TZUGFeRDTaxTypes.ILL, TZUGFeRDTaxTypesExtensions.FromString('ILL')); |
| 68 | + Assert.AreEqual(TZUGFeRDTaxTypes.IMP, TZUGFeRDTaxTypesExtensions.FromString('IMP')); |
| 69 | + Assert.AreEqual(TZUGFeRDTaxTypes.IND, TZUGFeRDTaxTypesExtensions.FromString('IND')); |
| 70 | + Assert.AreEqual(TZUGFeRDTaxTypes.LAC, TZUGFeRDTaxTypesExtensions.FromString('LAC')); |
| 71 | + Assert.AreEqual(TZUGFeRDTaxTypes.LCN, TZUGFeRDTaxTypesExtensions.FromString('LCN')); |
| 72 | + Assert.AreEqual(TZUGFeRDTaxTypes.LDP, TZUGFeRDTaxTypesExtensions.FromString('LDP')); |
| 73 | + Assert.AreEqual(TZUGFeRDTaxTypes.LOC, TZUGFeRDTaxTypesExtensions.FromString('LOC')); |
| 74 | + Assert.AreEqual(TZUGFeRDTaxTypes.LST, TZUGFeRDTaxTypesExtensions.FromString('LST')); |
| 75 | + Assert.AreEqual(TZUGFeRDTaxTypes.MCA, TZUGFeRDTaxTypesExtensions.FromString('MCA')); |
| 76 | + Assert.AreEqual(TZUGFeRDTaxTypes.MCD, TZUGFeRDTaxTypesExtensions.FromString('MCD')); |
| 77 | + Assert.AreEqual(TZUGFeRDTaxTypes.OTH, TZUGFeRDTaxTypesExtensions.FromString('OTH')); |
| 78 | + Assert.AreEqual(TZUGFeRDTaxTypes.PDB, TZUGFeRDTaxTypesExtensions.FromString('PDB')); |
| 79 | + Assert.AreEqual(TZUGFeRDTaxTypes.PDC, TZUGFeRDTaxTypesExtensions.FromString('PDC')); |
| 80 | + Assert.AreEqual(TZUGFeRDTaxTypes.PRF, TZUGFeRDTaxTypesExtensions.FromString('PRF')); |
| 81 | + Assert.AreEqual(TZUGFeRDTaxTypes.SCN, TZUGFeRDTaxTypesExtensions.FromString('SCN')); |
| 82 | + Assert.AreEqual(TZUGFeRDTaxTypes.SSS, TZUGFeRDTaxTypesExtensions.FromString('SSS')); |
| 83 | + Assert.AreEqual(TZUGFeRDTaxTypes.SIT, TZUGFeRDTaxTypesExtensions.FromString('SIT')); |
| 84 | + Assert.AreEqual(TZUGFeRDTaxTypes.SUP, TZUGFeRDTaxTypesExtensions.FromString('SUP')); |
| 85 | + Assert.AreEqual(TZUGFeRDTaxTypes.SUR, TZUGFeRDTaxTypesExtensions.FromString('SUR')); |
| 86 | + Assert.AreEqual(TZUGFeRDTaxTypes.SWT, TZUGFeRDTaxTypesExtensions.FromString('SWT')); |
| 87 | + Assert.AreEqual(TZUGFeRDTaxTypes.TAC, TZUGFeRDTaxTypesExtensions.FromString('TAC')); |
| 88 | + Assert.AreEqual(TZUGFeRDTaxTypes.TOT, TZUGFeRDTaxTypesExtensions.FromString('TOT')); |
| 89 | + Assert.AreEqual(TZUGFeRDTaxTypes.TOX, TZUGFeRDTaxTypesExtensions.FromString('TOX')); |
| 90 | + Assert.AreEqual(TZUGFeRDTaxTypes.TTA, TZUGFeRDTaxTypesExtensions.FromString('TTA')); |
| 91 | + Assert.AreEqual(TZUGFeRDTaxTypes.VAD, TZUGFeRDTaxTypesExtensions.FromString('VAD')); |
| 92 | + Assert.AreEqual(TZUGFeRDTaxTypes.VAT, TZUGFeRDTaxTypesExtensions.FromString('VAT')); |
| 93 | + Assert.AreEqual(TZUGFeRDTaxTypes.Unknown, TZUGFeRDTaxTypesExtensions.FromString('Unknown')); |
| 94 | + Assert.AreEqual(TZUGFeRDTaxTypes.Unknown, TZUGFeRDTaxTypesExtensions.FromString('Invalid')); |
| 95 | +end; |
| 96 | + |
| 97 | +procedure TZUGFeRDTaxTypesTest.TestEnumToString; |
| 98 | +begin |
| 99 | + Assert.AreEqual('AAA', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAA)); |
| 100 | + Assert.AreEqual('AAB', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAB)); |
| 101 | + Assert.AreEqual('AAC', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAC)); |
| 102 | + Assert.AreEqual('AAD', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAD)); |
| 103 | + Assert.AreEqual('AAE', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAE)); |
| 104 | + Assert.AreEqual('AAF', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAF)); |
| 105 | + Assert.AreEqual('AAG', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAG)); |
| 106 | + Assert.AreEqual('AAH', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAH)); |
| 107 | + Assert.AreEqual('AAI', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAI)); |
| 108 | + Assert.AreEqual('AAJ', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAJ)); |
| 109 | + Assert.AreEqual('AAK', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAK)); |
| 110 | + Assert.AreEqual('AAL', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAL)); |
| 111 | + Assert.AreEqual('AAM', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.AAM)); |
| 112 | + Assert.AreEqual('ADD', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.ADD)); |
| 113 | + Assert.AreEqual('BOL', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.BOL)); |
| 114 | + Assert.AreEqual('CAP', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.CAP)); |
| 115 | + Assert.AreEqual('CAR', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.CAR)); |
| 116 | + Assert.AreEqual('COC', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.COC)); |
| 117 | + Assert.AreEqual('CST', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.CST)); |
| 118 | + Assert.AreEqual('CUD', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.CUD)); |
| 119 | + Assert.AreEqual('CVD', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.CVD)); |
| 120 | + Assert.AreEqual('ENV', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.ENV)); |
| 121 | + Assert.AreEqual('EXC', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.EXC)); |
| 122 | + Assert.AreEqual('EXP', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.EXP)); |
| 123 | + Assert.AreEqual('FET', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.FET)); |
| 124 | + Assert.AreEqual('FRE', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.FRE)); |
| 125 | + Assert.AreEqual('GCN', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.GCN)); |
| 126 | + Assert.AreEqual('GST', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.GST)); |
| 127 | + Assert.AreEqual('ILL', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.ILL)); |
| 128 | + Assert.AreEqual('IMP', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.IMP)); |
| 129 | + Assert.AreEqual('IND', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.IND)); |
| 130 | + Assert.AreEqual('LAC', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.LAC)); |
| 131 | + Assert.AreEqual('LCN', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.LCN)); |
| 132 | + Assert.AreEqual('LDP', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.LDP)); |
| 133 | + Assert.AreEqual('LOC', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.LOC)); |
| 134 | + Assert.AreEqual('LST', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.LST)); |
| 135 | + Assert.AreEqual('MCA', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.MCA)); |
| 136 | + Assert.AreEqual('MCD', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.MCD)); |
| 137 | + Assert.AreEqual('OTH', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.OTH)); |
| 138 | + Assert.AreEqual('PDB', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.PDB)); |
| 139 | + Assert.AreEqual('PDC', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.PDC)); |
| 140 | + Assert.AreEqual('PRF', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.PRF)); |
| 141 | + Assert.AreEqual('SCN', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.SCN)); |
| 142 | + Assert.AreEqual('SSS', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.SSS)); |
| 143 | + Assert.AreEqual('SIT', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.SIT)); |
| 144 | + Assert.AreEqual('SUP', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.SUP)); |
| 145 | + Assert.AreEqual('SUR', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.SUR)); |
| 146 | + Assert.AreEqual('SWT', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.SWT)); |
| 147 | + Assert.AreEqual('TAC', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.TAC)); |
| 148 | + Assert.AreEqual('TOT', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.TOT)); |
| 149 | + Assert.AreEqual('TOX', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.TOX)); |
| 150 | + Assert.AreEqual('TTA', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.TTA)); |
| 151 | + Assert.AreEqual('VAD', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.VAD)); |
| 152 | + Assert.AreEqual('VAT', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.VAT)); |
| 153 | + Assert.AreEqual('Unknown', TZUGFeRDTaxTypesExtensions.EnumToString(TZUGFeRDTaxTypes.Unknown)); |
| 154 | +end; |
| 155 | + |
| 156 | +initialization |
| 157 | + |
| 158 | +//I was hoping to use RTTI to discover the TestFixture classes, however unlike .NET |
| 159 | +//if we don't touch the class somehow then the linker will remove |
| 160 | +//the class from the resulting exe. |
| 161 | +//We could just do this: |
| 162 | +//TMyExampleTests.ClassName; |
| 163 | +//TExampleFixture2.ClassName; |
| 164 | +//which is enough to make the compiler link the classes into the exe, but that seems a |
| 165 | +//bit redundent so I guess we'll just use manual registration. If you use the |
| 166 | +//{$STRONGLINKTYPES ON} compiler directive then it will link the TestFixtures in and you |
| 167 | +//can use RTTI. The downside to that is the resulting exe will potentially much larger. |
| 168 | +//Not sure which version {$STRONGLINKTYPES ON} was introduced so we'll allow RTTI and |
| 169 | +//manual registration for now. |
| 170 | + |
| 171 | +// TDUnitX.RegisterTestFixture(TZUGFeRDTaxTypesTest); |
| 172 | + |
| 173 | +end. |
0 commit comments