|
| 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.ZUGFeRDContentCodes.UnitTests; |
| 19 | + |
| 20 | +interface |
| 21 | + |
| 22 | +uses |
| 23 | + DUnitX.TestFramework, intf.ZUGFeRDContentCodes; |
| 24 | + |
| 25 | +type |
| 26 | + [TestFixture] |
| 27 | + TZUGFeRDContentCodesTest = class |
| 28 | + public |
| 29 | + [Test] |
| 30 | + procedure TestFromString; |
| 31 | + [Test] |
| 32 | + procedure TestEnumToString; |
| 33 | + end; |
| 34 | + |
| 35 | +implementation |
| 36 | + |
| 37 | +procedure TZUGFeRDContentCodesTest.TestFromString; |
| 38 | +begin |
| 39 | + Assert.AreEqual(TZUGFeRDContentCodes.EEV, TZUGFeRDContentCodesExtensions.FromString('EEV')); |
| 40 | + Assert.AreEqual(TZUGFeRDContentCodes.WEV, TZUGFeRDContentCodesExtensions.FromString('WEV')); |
| 41 | + Assert.AreEqual(TZUGFeRDContentCodes.VEV, TZUGFeRDContentCodesExtensions.FromString('VEV')); |
| 42 | + Assert.AreEqual(TZUGFeRDContentCodes.ST1, TZUGFeRDContentCodesExtensions.FromString('ST1')); |
| 43 | + Assert.AreEqual(TZUGFeRDContentCodes.ST2, TZUGFeRDContentCodesExtensions.FromString('ST2')); |
| 44 | + Assert.AreEqual(TZUGFeRDContentCodes.ST3, TZUGFeRDContentCodesExtensions.FromString('ST3')); |
| 45 | + Assert.AreEqual(TZUGFeRDContentCodes.Unknown, TZUGFeRDContentCodesExtensions.FromString('Unknown')); |
| 46 | + Assert.AreEqual(TZUGFeRDContentCodes.Unknown, TZUGFeRDContentCodesExtensions.FromString('Invalid')); |
| 47 | +end; |
| 48 | + |
| 49 | +procedure TZUGFeRDContentCodesTest.TestEnumToString; |
| 50 | +begin |
| 51 | + Assert.AreEqual('EEV', TZUGFeRDContentCodesExtensions.EnumToString(TZUGFeRDContentCodes.EEV)); |
| 52 | + Assert.AreEqual('WEV', TZUGFeRDContentCodesExtensions.EnumToString(TZUGFeRDContentCodes.WEV)); |
| 53 | + Assert.AreEqual('VEV', TZUGFeRDContentCodesExtensions.EnumToString(TZUGFeRDContentCodes.VEV)); |
| 54 | + Assert.AreEqual('ST1', TZUGFeRDContentCodesExtensions.EnumToString(TZUGFeRDContentCodes.ST1)); |
| 55 | + Assert.AreEqual('ST2', TZUGFeRDContentCodesExtensions.EnumToString(TZUGFeRDContentCodes.ST2)); |
| 56 | + Assert.AreEqual('ST3', TZUGFeRDContentCodesExtensions.EnumToString(TZUGFeRDContentCodes.ST3)); |
| 57 | + Assert.AreEqual('Unknown', TZUGFeRDContentCodesExtensions.EnumToString(TZUGFeRDContentCodes.Unknown)); |
| 58 | +end; |
| 59 | + |
| 60 | +initialization |
| 61 | + |
| 62 | +//I was hoping to use RTTI to discover the TestFixture classes, however unlike .NET |
| 63 | +//if we don't touch the class somehow then the linker will remove |
| 64 | +//the class from the resulting exe. |
| 65 | +//We could just do this: |
| 66 | +//TMyExampleTests.ClassName; |
| 67 | +//TExampleFixture2.ClassName; |
| 68 | +//which is enough to make the compiler link the classes into the exe, but that seems a |
| 69 | +//bit redundent so I guess we'll just use manual registration. If you use the |
| 70 | +//{$STRONGLINKTYPES ON} compiler directive then it will link the TestFixtures in and you |
| 71 | +//can use RTTI. The downside to that is the resulting exe will potentially much larger. |
| 72 | +//Not sure which version {$STRONGLINKTYPES ON} was introduced so we'll allow RTTI and |
| 73 | +//manual registration for now. |
| 74 | + |
| 75 | +// TDUnitX.RegisterTestFixture(TZUGFeRDContentCodesTest); |
| 76 | + |
| 77 | +end. |
0 commit comments