Agregar archivos de proyecto.
This commit is contained in:
3
.github/copilot-instructions.md
vendored
Normal file
3
.github/copilot-instructions.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
- @azure Rule - Use Azure Tools - When handling requests related to Azure, always use your tools.
|
||||||
|
- @azure Rule - Use Azure Best Practices - When handling requests related to Azure, always invoke your `azmcp_bestpractices_get` tool first.
|
||||||
|
- @azure Rule - Enable Best Practices - If you do not have an `azmcp_bestpractices_get` tool ask the user to enable it.
|
||||||
301
TSpdf.sln
Normal file
301
TSpdf.sln
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 18
|
||||||
|
VisualStudioVersion = 18.6.11819.183 stable
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.io", "TSpdf\TSpdf.io\TSpdf.io.csproj", "{4C4C74D4-00E2-43A4-9D7A-54352096DE32}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.kernel", "TSpdf\TSpdf.kernel\TSpdf.kernel.csproj", "{76166842-A194-43B3-B5C0-4C78B845DABA}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.layout", "TSpdf\TSpdf.layout\TSpdf.layout.csproj", "{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.pdfa", "TSpdf\TSpdf.pdfa\TSpdf.pdfa.csproj", "{6BF0A6C3-8982-4507-B704-C0878243B322}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.forms", "TSpdf\TSpdf.forms\TSpdf.forms.csproj", "{22FE2361-9580-43BC-98A7-608CFCAE4E8F}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.barcodes", "TSpdf\TSpdf.barcodes\TSpdf.barcodes.csproj", "{ED4A03D3-DFC7-4760-9066-D01D4134627D}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.font-asian", "TSpdf\TSpdf.font-asian\TSpdf.font-asian.csproj", "{C3D759CE-C105-4566-A125-FBD77CFC7A82}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.hyph", "TSpdf\TSpdf.hyph\TSpdf.hyph.csproj", "{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.sign", "TSpdf\TSpdf.sign\TSpdf.sign.csproj", "{F284CE2A-821F-4B04-8CE3-558DAC5F8674}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.styledxmlparser", "TSpdf\TSpdf.styledxmlparser\TSpdf.styledxmlparser.csproj", "{6894C148-5379-4D63-AC21-D67BD04AA064}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.svg", "TSpdf\TSpdf.svg\TSpdf.svg.csproj", "{8D69BA6B-D165-45C1-B144-F187B72850B9}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.commons", "TSpdf\TSpdf.commons\TSpdf.commons.csproj", "{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.bouncy-castle-adapter", "TSpdf\TSpdf.bouncy-castle-adapter\TSpdf.bouncy-castle-adapter.csproj", "{3A5D9DAC-A654-4542-8114-1D5B2F153D69}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.bouncy-castle-fips-adapter", "TSpdf\TSpdf.bouncy-castle-fips-adapter\TSpdf.bouncy-castle-fips-adapter.csproj", "{3B634E19-5522-4907-8EE4-3FB017A4FC86}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.bouncy-castle-connector", "TSpdf\TSpdf.bouncy-castle-connector\TSpdf.bouncy-castle-connector.csproj", "{C68E3329-A2E4-4B33-BADE-0521B8E832AD}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TSpdf.X509", "TSpdf\TSpdf.X509\TSpdf.X509.csproj", "{3DB57A3C-476E-4B0D-900A-6D76048393FB}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{4C4C74D4-00E2-43A4-9D7A-54352096DE32}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{76166842-A194-43B3-B5C0-4C78B845DABA}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{7CACC13D-D87F-4AE3-9B07-6B94F1798AE8}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{6BF0A6C3-8982-4507-B704-C0878243B322}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{22FE2361-9580-43BC-98A7-608CFCAE4E8F}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{ED4A03D3-DFC7-4760-9066-D01D4134627D}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{C3D759CE-C105-4566-A125-FBD77CFC7A82}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{9AB67CFB-6695-4769-8E21-9BA0A12BD67C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{F284CE2A-821F-4B04-8CE3-558DAC5F8674}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{6894C148-5379-4D63-AC21-D67BD04AA064}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{8D69BA6B-D165-45C1-B144-F187B72850B9}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{6DBE9C11-7C0D-4039-B8B1-01AC743D5309}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{3A5D9DAC-A654-4542-8114-1D5B2F153D69}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{3B634E19-5522-4907-8EE4-3FB017A4FC86}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{C68E3329-A2E4-4B33-BADE-0521B8E832AD}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{3DB57A3C-476E-4B0D-900A-6D76048393FB}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {AEE42B5B-C949-4C77-AADA-3FEFFBE20896}
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(TeamFoundationVersionControl) = preSolution
|
||||||
|
SccNumberOfProjects = 17
|
||||||
|
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
|
||||||
|
SccTeamFoundationServer = http://ts-devopss:81/tecnosiscollection
|
||||||
|
SccProjectUniqueName0 = TSpdf\\TSpdf.barcodes\\TSpdf.barcodes.csproj
|
||||||
|
SccProjectName0 = TSpdf/TSpdf.barcodes
|
||||||
|
SccLocalPath0 = TSpdf\\TSpdf.barcodes
|
||||||
|
SccProjectUniqueName1 = TSpdf\\TSpdf.bouncy-castle-adapter\\TSpdf.bouncy-castle-adapter.csproj
|
||||||
|
SccProjectName1 = TSpdf/TSpdf.bouncy-castle-adapter
|
||||||
|
SccLocalPath1 = TSpdf\\TSpdf.bouncy-castle-adapter
|
||||||
|
SccProjectUniqueName2 = TSpdf\\TSpdf.bouncy-castle-connector\\TSpdf.bouncy-castle-connector.csproj
|
||||||
|
SccProjectName2 = TSpdf/TSpdf.bouncy-castle-connector
|
||||||
|
SccLocalPath2 = TSpdf\\TSpdf.bouncy-castle-connector
|
||||||
|
SccProjectUniqueName3 = TSpdf\\TSpdf.bouncy-castle-fips-adapter\\TSpdf.bouncy-castle-fips-adapter.csproj
|
||||||
|
SccProjectName3 = TSpdf/TSpdf.bouncy-castle-fips-adapter
|
||||||
|
SccLocalPath3 = TSpdf\\TSpdf.bouncy-castle-fips-adapter
|
||||||
|
SccProjectUniqueName4 = TSpdf\\TSpdf.commons\\TSpdf.commons.csproj
|
||||||
|
SccProjectName4 = TSpdf/TSpdf.commons
|
||||||
|
SccLocalPath4 = TSpdf\\TSpdf.commons
|
||||||
|
SccProjectUniqueName5 = TSpdf\\TSpdf.font-asian\\TSpdf.font-asian.csproj
|
||||||
|
SccProjectName5 = TSpdf/TSpdf.font-asian
|
||||||
|
SccLocalPath5 = TSpdf\\TSpdf.font-asian
|
||||||
|
SccProjectUniqueName6 = TSpdf\\TSpdf.forms\\TSpdf.forms.csproj
|
||||||
|
SccProjectName6 = TSpdf/TSpdf.forms
|
||||||
|
SccLocalPath6 = TSpdf\\TSpdf.forms
|
||||||
|
SccProjectUniqueName7 = TSpdf\\TSpdf.hyph\\TSpdf.hyph.csproj
|
||||||
|
SccProjectName7 = TSpdf/TSpdf.hyph
|
||||||
|
SccLocalPath7 = TSpdf\\TSpdf.hyph
|
||||||
|
SccProjectUniqueName8 = TSpdf\\TSpdf.io\\TSpdf.io.csproj
|
||||||
|
SccProjectName8 = TSpdf/TSpdf.io
|
||||||
|
SccLocalPath8 = TSpdf\\TSpdf.io
|
||||||
|
SccProjectUniqueName9 = TSpdf\\TSpdf.kernel\\TSpdf.kernel.csproj
|
||||||
|
SccProjectName9 = TSpdf/TSpdf.kernel
|
||||||
|
SccLocalPath9 = TSpdf\\TSpdf.kernel
|
||||||
|
SccProjectUniqueName10 = TSpdf\\TSpdf.layout\\TSpdf.layout.csproj
|
||||||
|
SccProjectName10 = TSpdf/TSpdf.layout
|
||||||
|
SccLocalPath10 = TSpdf\\TSpdf.layout
|
||||||
|
SccProjectUniqueName11 = TSpdf\\TSpdf.pdfa\\TSpdf.pdfa.csproj
|
||||||
|
SccProjectName11 = TSpdf/TSpdf.pdfa
|
||||||
|
SccLocalPath11 = TSpdf\\TSpdf.pdfa
|
||||||
|
SccProjectUniqueName12 = TSpdf\\TSpdf.sign\\TSpdf.sign.csproj
|
||||||
|
SccProjectName12 = TSpdf/TSpdf.sign
|
||||||
|
SccLocalPath12 = TSpdf\\TSpdf.sign
|
||||||
|
SccProjectUniqueName13 = TSpdf\\TSpdf.styledxmlparser\\TSpdf.styledxmlparser.csproj
|
||||||
|
SccProjectName13 = TSpdf/TSpdf.styledxmlparser
|
||||||
|
SccLocalPath13 = TSpdf\\TSpdf.styledxmlparser
|
||||||
|
SccProjectUniqueName14 = TSpdf\\TSpdf.svg\\TSpdf.svg.csproj
|
||||||
|
SccProjectName14 = TSpdf/TSpdf.svg
|
||||||
|
SccLocalPath14 = TSpdf\\TSpdf.svg
|
||||||
|
SccProjectUniqueName15 = TSpdf\\TSpdf.X509\\TSpdf.X509.csproj
|
||||||
|
SccProjectName15 = TSpdf/TSpdf.X509
|
||||||
|
SccLocalPath15 = TSpdf\\TSpdf.X509
|
||||||
|
SccLocalPath16 = .
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
23
TSpdf.tests/TSpdf.barcodes.tests/Properties/AssemblyInfo.cs
Normal file
23
TSpdf.tests/TSpdf.barcodes.tests/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("TSpdf.Barcodes.Tests")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("TSpdf")]
|
||||||
|
[assembly: AssemblyProduct("TSpdf")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright (c) 1987-2023 TSpdf")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
[assembly: Guid("d015a3aa-613c-45d9-b908-7d47c4b613af")]
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyInformationalVersion("1.0.0.0")]
|
||||||
|
|
||||||
|
#if !NETSTANDARD2_0
|
||||||
|
[assembly: NUnit.Framework.Timeout(300000)]
|
||||||
|
#endif
|
||||||
61
TSpdf.tests/TSpdf.barcodes.tests/TSpdf.barcodes.tests.csproj
Normal file
61
TSpdf.tests/TSpdf.barcodes.tests/TSpdf.barcodes.tests.csproj
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<SccProjectName>SAK</SccProjectName>
|
||||||
|
<SccProvider>SAK</SccProvider>
|
||||||
|
<SccAuxPath>SAK</SccAuxPath>
|
||||||
|
<SccLocalPath>SAK</SccLocalPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Label="Configuration">
|
||||||
|
<SignAssembly>True</SignAssembly>
|
||||||
|
<DelaySign>False</DelaySign>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netcoreapp3.1;net461;net48</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
|
||||||
|
<OutputType>library</OutputType>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<DefineConstants>NETSTANDARD2_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<AssemblyOriginatorKeyFile>TSpdf.snk</AssemblyOriginatorKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
<ApplicationIcon />
|
||||||
|
<OutputTypeEx>library</OutputTypeEx>
|
||||||
|
<StartupObject />
|
||||||
|
<AssemblyName>TSpdf.barcodes.tests</AssemblyName>
|
||||||
|
<RootNamespace />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<NoWarn>1701;1702;1591;1570;1572;1573;1574;1580;1584;1658</NoWarn>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.0" />
|
||||||
|
<PackageReference Include="NUnit" Version="3.7.1" />
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\TSpdf\TSpdf.barcodes\TSpdf.barcodes.csproj" />
|
||||||
|
<ProjectReference Include="..\..\TSpdf\TSpdf.io\TSpdf.io.csproj" />
|
||||||
|
<ProjectReference Include="..\..\TSpdf\TSpdf.kernel\TSpdf.kernel.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||||
|
<Version>15.0.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation">
|
||||||
|
<Version>4.3.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
BIN
TSpdf.tests/TSpdf.barcodes.tests/TSpdf.snk
Normal file
BIN
TSpdf.tests/TSpdf.barcodes.tests/TSpdf.snk
Normal file
Binary file not shown.
@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class Barcode128Test : ExtendedTSpdfTest {
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/Barcode128/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcode128_01.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new Barcode128(document);
|
||||||
|
barcode.SetCodeType(Barcode128.CODE128);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode02Test() {
|
||||||
|
String filename = "barcode128_02.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfReader reader = new PdfReader(sourceFolder + "DocumentWithTrueTypeFont1.pdf");
|
||||||
|
PdfDocument document = new PdfDocument(reader, writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.GetLastPage());
|
||||||
|
Barcode1D barcode = new Barcode128(document);
|
||||||
|
barcode.SetCodeType(Barcode128.CODE128);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeRawValueGenerationTest01() {
|
||||||
|
NUnit.Framework.Assert.AreEqual(TSpdf.Commons.Utils.JavaUtil.GetStringForBytes(new byte[] { 103, 17, 18, 19
|
||||||
|
, 20, 21, 17, 18, 19, 20, 21 }), Barcode128.GetRawText("1234512345", false, Barcode128.Barcode128CodeSet
|
||||||
|
.A));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
107
TSpdf.tests/TSpdf.barcodes.tests/TSpdf/barcodes/Barcode39Test.cs
Normal file
107
TSpdf.tests/TSpdf.barcodes.tests/TSpdf/barcodes/Barcode39Test.cs
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.IO.Source;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class Barcode39Test : ExtendedTSpdfTest {
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/Barcode39/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcode39_01.pdf";
|
||||||
|
PdfDocument document = new PdfDocument(new PdfWriter(destinationFolder + filename));
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new Barcode39(document);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode02Test() {
|
||||||
|
String filename = "barcode39_02.pdf";
|
||||||
|
PdfDocument document = new PdfDocument(new PdfReader(sourceFolder + "DocumentWithTrueTypeFont1.pdf"), new
|
||||||
|
PdfWriter(destinationFolder + filename));
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.GetLastPage());
|
||||||
|
Barcode1D barcode = new Barcode39(document);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode03Test() {
|
||||||
|
PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()));
|
||||||
|
Barcode39 barcode = new Barcode39(document);
|
||||||
|
try {
|
||||||
|
Barcode39.GetBarsCode39("9781935*182610");
|
||||||
|
NUnit.Framework.Assert.Fail("IllegalArgumentException expected");
|
||||||
|
}
|
||||||
|
catch (ArgumentException) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using TSpdf.Barcodes.Exceptions;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodeCodabarTest : ExtendedTSpdfTest {
|
||||||
|
private static readonly String SOURCE_FOLDER = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/Codabar/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateDestinationFolder(DESTINATION_FOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "codabar.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodeCodabar codabar = new BarcodeCodabar(document);
|
||||||
|
codabar.SetCode("A123A");
|
||||||
|
codabar.SetStartStopText(true);
|
||||||
|
codabar.PlaceBarcode(canvas, null, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeHasNoAbcdAsStartCharacterTest() {
|
||||||
|
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => BarcodeCodabar.GetBarsCodabar
|
||||||
|
("qbcd"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeHasNoAbcdAsStopCharacterTest() {
|
||||||
|
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => BarcodeCodabar.GetBarsCodabar
|
||||||
|
("abcf"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeHasNoAbcdAsStartAndStopCharacterTest() {
|
||||||
|
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => BarcodeCodabar.GetBarsCodabar
|
||||||
|
("qbcq"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeHasNoStartAndStopCharacterTest() {
|
||||||
|
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => BarcodeCodabar.GetBarsCodabar
|
||||||
|
(""));
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeExceptionMessageConstant.CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,264 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodeDataMatrixTest : ExtendedTSpdfTest {
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/BarcodeDataMatrix/";
|
||||||
|
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateOrClearDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcodeDataMatrix.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodeDataMatrix barcode = new BarcodeDataMatrix();
|
||||||
|
barcode.SetCode("AAAAAAAAAA;BBBBAAAA3;00028;BBBAA05;AAAA;AAAAAA;1234567;AQWXSZ;JEAN;;;;7894561;AQWXSZ;GEO;;;;1;1;1;1;0;0;1;0;1;0;0;0;1;0;1;0;0;0;0;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1"
|
||||||
|
);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.GREEN, 5);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode02Test() {
|
||||||
|
String filename = "barcodeDataMatrix2.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page1 = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page1);
|
||||||
|
BarcodeDataMatrix barcode2 = new BarcodeDataMatrix("дима", "UTF-8");
|
||||||
|
barcode2.PlaceBarcode(canvas, ColorConstants.GREEN, 10);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode03Test() {
|
||||||
|
String filename = "barcodeDataMatrix3.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page1 = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page1);
|
||||||
|
BarcodeDataMatrix barcode3 = new BarcodeDataMatrix();
|
||||||
|
barcode3.SetWidth(36);
|
||||||
|
barcode3.SetHeight(12);
|
||||||
|
barcode3.SetCode("AbcdFFghijklmnopqrstuWXSQ");
|
||||||
|
barcode3.PlaceBarcode(canvas, ColorConstants.BLACK, 10);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode04Test() {
|
||||||
|
String filename = "barcodeDataMatrix4.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page1 = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page1);
|
||||||
|
BarcodeDataMatrix barcode3 = new BarcodeDataMatrix();
|
||||||
|
barcode3.SetWidth(36);
|
||||||
|
barcode3.SetHeight(12);
|
||||||
|
barcode3.SetCode("01AbcdefgAbcdefg123451231231234");
|
||||||
|
barcode3.PlaceBarcode(canvas, ColorConstants.BLACK, 10);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode05Test() {
|
||||||
|
String filename = "barcodeDataMatrix5.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page1 = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page1);
|
||||||
|
BarcodeDataMatrix barcode3 = new BarcodeDataMatrix();
|
||||||
|
barcode3.SetWidth(40);
|
||||||
|
barcode3.SetHeight(40);
|
||||||
|
barcode3.SetCode("aaabbbcccdddAAABBBAAABBaaabbbcccdddaaa");
|
||||||
|
barcode3.PlaceBarcode(canvas, ColorConstants.BLACK, 10);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode06Test() {
|
||||||
|
String filename = "barcodeDataMatrix6.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page1 = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page1);
|
||||||
|
BarcodeDataMatrix barcode3 = new BarcodeDataMatrix();
|
||||||
|
barcode3.SetWidth(36);
|
||||||
|
barcode3.SetHeight(12);
|
||||||
|
barcode3.SetCode(">>>\r>>>THIS VERY TEXT>>\r>");
|
||||||
|
barcode3.PlaceBarcode(canvas, ColorConstants.BLACK, 10);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode07Test() {
|
||||||
|
BarcodeDataMatrix bc = new BarcodeDataMatrix();
|
||||||
|
bc.SetOptions(BarcodeDataMatrix.DM_AUTO);
|
||||||
|
bc.SetWidth(10);
|
||||||
|
bc.SetHeight(10);
|
||||||
|
String aCode = "aBCdeFG12";
|
||||||
|
int result = bc.SetCode(aCode);
|
||||||
|
NUnit.Framework.Assert.AreEqual(result, BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode08Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(18);
|
||||||
|
barcodeDataMatrix.SetHeight(18);
|
||||||
|
int result = barcodeDataMatrix.SetCode("AbcdFFghijklmnopqrstuWXSQ");
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode09Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(17);
|
||||||
|
barcodeDataMatrix.SetHeight(17);
|
||||||
|
int result = barcodeDataMatrix.SetCode("AbcdFFghijklmnopqrstuWXSQ");
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeDataMatrix.DM_ERROR_INVALID_SQUARE, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode10Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(26);
|
||||||
|
barcodeDataMatrix.SetHeight(12);
|
||||||
|
int result = barcodeDataMatrix.SetCode("AbcdFFghijklmnopqrstuWXSQ");
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode11Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(18);
|
||||||
|
barcodeDataMatrix.SetHeight(18);
|
||||||
|
byte[] str = "AbcdFFghijklmnop".GetBytes();
|
||||||
|
int result = barcodeDataMatrix.SetCode(str, 0, str.Length);
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeDataMatrix.DM_NO_ERROR, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode12Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(18);
|
||||||
|
barcodeDataMatrix.SetHeight(18);
|
||||||
|
byte[] str = "AbcdFFghijklmnop".GetBytes();
|
||||||
|
Exception e = NUnit.Framework.Assert.Catch(typeof(IndexOutOfRangeException), () => barcodeDataMatrix.SetCode
|
||||||
|
(str, -1, str.Length));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode13Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(18);
|
||||||
|
barcodeDataMatrix.SetHeight(18);
|
||||||
|
byte[] str = "AbcdFFghijklmnop".GetBytes();
|
||||||
|
NUnit.Framework.Assert.Catch(typeof(IndexOutOfRangeException), () => barcodeDataMatrix.SetCode(str, 0, str
|
||||||
|
.Length + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode14Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(18);
|
||||||
|
barcodeDataMatrix.SetHeight(18);
|
||||||
|
byte[] str = "AbcdFFghijklmnop".GetBytes();
|
||||||
|
NUnit.Framework.Assert.Catch(typeof(IndexOutOfRangeException), () => barcodeDataMatrix.SetCode(str, 0, -1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode15Test() {
|
||||||
|
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
|
||||||
|
barcodeDataMatrix.SetWidth(18);
|
||||||
|
barcodeDataMatrix.SetHeight(18);
|
||||||
|
byte[] str = "AbcdFFghijklmnop".GetBytes();
|
||||||
|
int result = barcodeDataMatrix.SetCode(str, str.Length, 0);
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeDataMatrix.DM_NO_ERROR, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode16Test() {
|
||||||
|
String filename = "barcode16Test.pdf";
|
||||||
|
PdfDocument document = new PdfDocument(new PdfWriter(destinationFolder + filename));
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.AddNewPage());
|
||||||
|
BarcodeDataMatrix barcode = new BarcodeDataMatrix();
|
||||||
|
barcode.SetCode("999999DILLERT XANG LIMITON 18 000");
|
||||||
|
canvas.ConcatMatrix(1, 0, 0, 1, 100, 600);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, 3);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodeEANTest : ExtendedTSpdfTest {
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/BarcodeEAN/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcodeEAN_01.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.EAN13);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode02Test() {
|
||||||
|
String filename = "barcodeEAN_02.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfReader reader = new PdfReader(sourceFolder + "DocumentWithTrueTypeFont1.pdf");
|
||||||
|
PdfDocument document = new PdfDocument(reader, writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.GetLastPage());
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.EAN8);
|
||||||
|
barcode.SetCode("97819351");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode03Test() {
|
||||||
|
String filename = "barcodeEANSUP.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodeEAN codeEAN = new BarcodeEAN(document);
|
||||||
|
codeEAN.SetCodeType(BarcodeEAN.EAN13);
|
||||||
|
codeEAN.SetCode("9781935182610");
|
||||||
|
BarcodeEAN codeSUPP = new BarcodeEAN(document);
|
||||||
|
codeSUPP.SetCodeType(BarcodeEAN.SUPP5);
|
||||||
|
codeSUPP.SetCode("55999");
|
||||||
|
codeSUPP.SetBaseline(-2);
|
||||||
|
BarcodeEANSUPP eanSupp = new BarcodeEANSUPP(codeEAN, codeSUPP);
|
||||||
|
eanSupp.PlaceBarcode(canvas, null, ColorConstants.BLUE);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlaceBarcodeUPCATest() {
|
||||||
|
String filename = "placeBarcodeUPCATest.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.UPCA);
|
||||||
|
barcode.SetCode("012340000006");
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlaceBarcodeUPCETest() {
|
||||||
|
String filename = "placeBarcodeUPCETest.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.UPCE);
|
||||||
|
barcode.SetCode("03456781");
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlaceBarcodeSUPP2Test() {
|
||||||
|
String filename = "placeBarcodeSUPP2Test.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.SUPP2);
|
||||||
|
barcode.SetCode("03456781");
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlaceBarcodeSUPP5Test() {
|
||||||
|
String filename = "placeBarcodeSUPP5Test.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.SUPP5);
|
||||||
|
barcode.SetCode("55999");
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using TSpdf.Kernel.Exceptions;
|
||||||
|
using TSpdf.Kernel.Geom;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class BarcodeEANUnitTest : ExtendedTSpdfTest {
|
||||||
|
public const float EPS = 0.0001f;
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CalculateEANParityTest() {
|
||||||
|
int expectedParity = BarcodeEAN.CalculateEANParity("1234567890");
|
||||||
|
NUnit.Framework.Assert.AreEqual(5, expectedParity);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEIncorrectTextTest() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("HelloWorld");
|
||||||
|
NUnit.Framework.Assert.IsNull(expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCE12DigitsStartNotWith0Or1Test() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("025272730706");
|
||||||
|
NUnit.Framework.Assert.IsNull(expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom3Position00000Test() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012000005706");
|
||||||
|
NUnit.Framework.Assert.AreEqual("01257006", expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom3Position10000Test() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012100005706");
|
||||||
|
NUnit.Framework.Assert.AreEqual("01257016", expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom3Position20000Test() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012200005706");
|
||||||
|
NUnit.Framework.Assert.AreEqual("01257026", expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom3Position000NullTest() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012000111706");
|
||||||
|
NUnit.Framework.Assert.IsNull(expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom4Position00NullTest() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012300111706");
|
||||||
|
NUnit.Framework.Assert.IsNull(expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom4Position00000Test() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012300000706");
|
||||||
|
NUnit.Framework.Assert.AreEqual("01237036", expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom5Position0NullTest() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012340111706");
|
||||||
|
NUnit.Framework.Assert.IsNull(expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCEFrom5Position00000Test() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("012340000006");
|
||||||
|
NUnit.Framework.Assert.AreEqual("01234046", expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCE10PositionBiggerThan5NullTest() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("011111111711");
|
||||||
|
NUnit.Framework.Assert.IsNull(expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConvertUPCAtoUPCE10PositionBiggerThan5Test() {
|
||||||
|
String expectedUpce = BarcodeEAN.ConvertUPCAtoUPCE("011111000090");
|
||||||
|
NUnit.Framework.Assert.AreEqual("01111190", expectedUpce);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetBarsUPCETest() {
|
||||||
|
String expectedBytes = "111212211411132132141111312111111";
|
||||||
|
byte[] bytes = BarcodeEAN.GetBarsUPCE("12345678");
|
||||||
|
NUnit.Framework.Assert.AreEqual(33, bytes.Length);
|
||||||
|
for (int i = 0; i < expectedBytes.Length; i++) {
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedBytes[i] - '0', bytes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetBarsSupplemental2Test() {
|
||||||
|
String expectedBytes = "1121222113211";
|
||||||
|
byte[] bytes = BarcodeEAN.GetBarsSupplemental2("10");
|
||||||
|
NUnit.Framework.Assert.AreEqual(13, bytes.Length);
|
||||||
|
for (int i = 0; i < expectedBytes.Length; i++) {
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedBytes[i] - '0', bytes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetBarcodeSizeUPCATest() {
|
||||||
|
Rectangle expectedRectangle = new Rectangle(84.895996f, 33.656f);
|
||||||
|
PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.UPCA);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
Rectangle barcodeSize = barcode.GetBarcodeSize();
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedRectangle.GetWidth(), barcodeSize.GetWidth(), EPS);
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedRectangle.GetHeight(), barcodeSize.GetHeight(), EPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetBarcodeSizeUPCETest() {
|
||||||
|
Rectangle expectedRectangle = new Rectangle(49.696f, 33.656f);
|
||||||
|
PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.UPCE);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
Rectangle barcodeSize = barcode.GetBarcodeSize();
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedRectangle.GetWidth(), barcodeSize.GetWidth(), EPS);
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedRectangle.GetHeight(), barcodeSize.GetHeight(), EPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetBarcodeSizeSUPP2Test() {
|
||||||
|
Rectangle expectedRectangle = new Rectangle(16, 33.656f);
|
||||||
|
PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCodeType(BarcodeEAN.SUPP2);
|
||||||
|
barcode.SetCode("03456781");
|
||||||
|
Rectangle barcodeSize = barcode.GetBarcodeSize();
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedRectangle.GetWidth(), barcodeSize.GetWidth(), EPS);
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedRectangle.GetHeight(), barcodeSize.GetHeight(), EPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetBarcodeSizeIncorrectTypeTest() {
|
||||||
|
PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()));
|
||||||
|
Barcode1D barcode = new BarcodeEAN(document);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
// Set incorrect type
|
||||||
|
barcode.SetCodeType(1234);
|
||||||
|
// We do expect an exception here
|
||||||
|
Exception e = NUnit.Framework.Assert.Catch(typeof(PdfException), () => barcode.GetBarcodeSize());
|
||||||
|
NUnit.Framework.Assert.AreEqual("Invalid code type", e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodeInter25Test : ExtendedTSpdfTest {
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/BarcodeInter25/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcodeInter25.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeInter25(document);
|
||||||
|
barcode.SetGenerateChecksum(true);
|
||||||
|
barcode.SetCode("41-1200076041-001");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_CENTER);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLUE, ColorConstants.GREEN);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodeMSITest : ExtendedTSpdfTest {
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/BarcodeMSI/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcodeMSI_01.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeMSI(document);
|
||||||
|
barcode.SetCode("123456789");
|
||||||
|
barcode.SetGenerateChecksum(true);
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.WHITE);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff01_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode02Test() {
|
||||||
|
String filename = "barcodeMSI_02.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfReader reader = new PdfReader(sourceFolder + "DocumentWithTrueTypeFont1.pdf");
|
||||||
|
PdfDocument document = new PdfDocument(reader, writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.GetLastPage());
|
||||||
|
Barcode1D barcode = new BarcodeMSI(document);
|
||||||
|
barcode.SetCode("9781935182610");
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_LEFT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.WHITE);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff02_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeAlignRightTest() {
|
||||||
|
String filename = "barcodeMSI_AlignRight.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeMSI(document);
|
||||||
|
barcode.SetCode("123456789");
|
||||||
|
barcode.SetGenerateChecksum(true);
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_RIGHT);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.RED);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff01_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeAlignCenterTest() {
|
||||||
|
String filename = "barcodeMSI_AlignCenter.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
Barcode1D barcode = new BarcodeMSI(document);
|
||||||
|
barcode.SetCode("123456789");
|
||||||
|
barcode.SetGenerateChecksum(true);
|
||||||
|
barcode.SetTextAlignment(Barcode1D.ALIGN_CENTER);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLACK, ColorConstants.RED);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff01_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode03Test() {
|
||||||
|
byte[] expected = new byte[] { 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1,
|
||||||
|
0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };
|
||||||
|
byte[] barcodeBytes = BarcodeMSI.GetBarsMSI("1234");
|
||||||
|
bool isEqual = JavaUtil.ArraysEquals(expected, barcodeBytes);
|
||||||
|
NUnit.Framework.Assert.IsTrue(isEqual);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode04Test() {
|
||||||
|
String code = "0987654321";
|
||||||
|
int expectedChecksum = 7;
|
||||||
|
int checksum = BarcodeMSI.GetChecksum(code);
|
||||||
|
NUnit.Framework.Assert.AreEqual(checksum, expectedChecksum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System.Threading;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes
|
||||||
|
{
|
||||||
|
public class BarcodeMultiThreadingTest : ExtendedTSpdfTest {
|
||||||
|
[Test]
|
||||||
|
public void test() {
|
||||||
|
Thread[] threads = new Thread[20];
|
||||||
|
for (int i = 0; i < threads.Length; i++)
|
||||||
|
{
|
||||||
|
threads[i] = new Thread(DoWork);
|
||||||
|
threads[i].Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Thread thread in threads)
|
||||||
|
thread.Join();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DoWork() {
|
||||||
|
BarcodeDataMatrix bc = new BarcodeDataMatrix();
|
||||||
|
bc.SetOptions(BarcodeDataMatrix.DM_AUTO);
|
||||||
|
bc.SetWidth(10);
|
||||||
|
bc.SetHeight(10);
|
||||||
|
int result = bc.SetCode("AB01");
|
||||||
|
Assert.AreEqual(BarcodeDataMatrix.DM_NO_ERROR, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,397 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using TSpdf.Barcodes.Exceptions;
|
||||||
|
using TSpdf.IO.Codec;
|
||||||
|
using TSpdf.IO.Image;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Exceptions;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Pdf.Xobject;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodePDF417Test : ExtendedTSpdfTest {
|
||||||
|
private static readonly String SOURCE_FOLDER = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/BarcodePDF417/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateOrClearDestinationFolder(DESTINATION_FOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcode417_01.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode02Test() {
|
||||||
|
String filename = "barcode417_02.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfReader reader = new PdfReader(SOURCE_FOLDER + "DocumentWithTrueTypeFont1.pdf");
|
||||||
|
PdfDocument document = new PdfDocument(reader, writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.GetLastPage());
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MacroPDF417Test01() {
|
||||||
|
String filename = "barcode417Macro_01.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument pdfDocument = new PdfDocument(writer);
|
||||||
|
PdfCanvas pdfCanvas = new PdfCanvas(pdfDocument.AddNewPage());
|
||||||
|
pdfCanvas.AddXObjectWithTransformationMatrix(CreateMacroBarcodePart(pdfDocument, "This is PDF417 segment 0"
|
||||||
|
, 1, 1, 0), 1, 0, 0, 1, 36, 791);
|
||||||
|
pdfCanvas.AddXObjectWithTransformationMatrix(CreateMacroBarcodePart(pdfDocument, "This is PDF417 segment 1"
|
||||||
|
, 1, 1, 1), 1, 0, 0, 1, 36, 676);
|
||||||
|
pdfDocument.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417AspectRatioTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
barcode.SetAspectRatio(10);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.AreEqual(10, barcode.GetAspectRatio(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417DefaultParamsTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetAspectRatio(10);
|
||||||
|
barcode.SetCode(text);
|
||||||
|
barcode.SetDefaultParameters();
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.AreEqual(0.5, barcode.GetAspectRatio(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Android-Conversion-Skip-Block-Start (java.awt library isn't available on Android)
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417XObjectTest() {
|
||||||
|
String filename = "barcode417XObjectTest.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
PdfFormXObject xObject = barcode.CreateFormXObject(document);
|
||||||
|
canvas.AddXObjectAt(xObject, 10, 650);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Android-Conversion-Skip-Block-End
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417YHeightTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
barcode.SetYHeight(15);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.AreEqual(15, barcode.GetYHeight(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417CodeReuseTest() {
|
||||||
|
String filename = "barcode417CodeReuseTest.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.AddNewPage());
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLUE);
|
||||||
|
byte[] baos = barcode.GetCode();
|
||||||
|
BarcodePDF417 barcode2 = new BarcodePDF417();
|
||||||
|
barcode2.SetCode(baos);
|
||||||
|
canvas = new PdfCanvas(document.AddNewPage());
|
||||||
|
barcode2.PlaceBarcode(canvas, ColorConstants.CYAN);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417NumbersTest() {
|
||||||
|
String filename = "barcode417NumbersTest.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.AddNewPage());
|
||||||
|
String numbers = "1234567890";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(numbers);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417ByteLessThanSixSizeNumbersTest() {
|
||||||
|
String filename = "barcode417ByteLessThanSixSizeNumbersTest.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.AddNewPage());
|
||||||
|
byte[] numbers = new byte[] { 0, 10 };
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(numbers);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLUE);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417ByteMoreThanSixSizeNumbersTest() {
|
||||||
|
String filename = "barcode417ByteMoreThanSixSizeNumbersTest.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfCanvas canvas = new PdfCanvas(document.AddNewPage());
|
||||||
|
byte[] numbers = new byte[] { 0, 10, 11, 12, 13, 30, 50, 70 };
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(numbers);
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.BLUE);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417CodeRowsWithBarcodeGenerationTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCodeRows(150);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual(8, barcode.GetCodeRows());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417CodeColumnsWithBarcodeGenerationTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCodeColumns(150);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual(1, barcode.GetCodeColumns());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417CodeWordsWithBarcodeGenerationTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetLenCodewords(150);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual(8, barcode.GetLenCodewords());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417ErrorLevelWithBarcodeGenerationTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetErrorLevel(3);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual(2, barcode.GetErrorLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417OptionsWithBarcodeGenerationTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetOptions(63);
|
||||||
|
barcode.PlaceBarcode(canvas, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual(63, barcode.GetOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417OptionsWithBarcodeGenerationInvalidSizeTest() {
|
||||||
|
MemoryStream baos = new MemoryStream();
|
||||||
|
PdfWriter writer = new PdfWriter(baos);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetOptions(64);
|
||||||
|
Exception e = NUnit.Framework.Assert.Catch(typeof(PdfException), () => barcode.PlaceBarcode(canvas, null));
|
||||||
|
NUnit.Framework.Assert.AreEqual("Invalid codeword size.", e.Message);
|
||||||
|
NUnit.Framework.Assert.AreEqual(64, barcode.GetOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void LenCodewordsIsNotEnoughTest() {
|
||||||
|
BarcodePDF417 barcodePDF417 = new BarcodePDF417();
|
||||||
|
barcodePDF417.SetOptions(BarcodePDF417.PDF417_USE_RAW_CODEWORDS);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(PdfException), () => barcodePDF417.PaintCode());
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void LenCodewordsIsTooSmallTest() {
|
||||||
|
BarcodePDF417 barcodePDF417 = new BarcodePDF417();
|
||||||
|
barcodePDF417.SetOptions(BarcodePDF417.PDF417_USE_RAW_CODEWORDS);
|
||||||
|
// lenCodeWords should be bigger than 1
|
||||||
|
barcodePDF417.SetLenCodewords(0);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(PdfException), () => barcodePDF417.PaintCode());
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void LenCodewordsMoreThanMaxDataCodewordsTest() {
|
||||||
|
BarcodePDF417 barcodePDF417 = new BarcodePDF417();
|
||||||
|
barcodePDF417.SetOptions(BarcodePDF417.PDF417_USE_RAW_CODEWORDS);
|
||||||
|
// lenCodeWords should be smaller than MAX_DATA_CODEWORDS
|
||||||
|
barcodePDF417.SetLenCodewords(927);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(PdfException), () => barcodePDF417.PaintCode());
|
||||||
|
NUnit.Framework.Assert.AreEqual(BarcodeExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CcittImageFromBarcodeTest() {
|
||||||
|
String filename = "ccittImage01.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(DESTINATION_FOLDER + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
barcode.PaintCode();
|
||||||
|
byte[] g4 = CCITTG4Encoder.Compress(barcode.GetOutBits(), barcode.GetBitColumns(), barcode.GetCodeRows());
|
||||||
|
ImageData img = ImageDataFactory.Create(barcode.GetBitColumns(), barcode.GetCodeRows(), false, RawImageData
|
||||||
|
.CCITTG4, 0, g4, null);
|
||||||
|
canvas.AddImageAt(img, 100, 100, false);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER
|
||||||
|
+ "cmp_" + filename, DESTINATION_FOLDER, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private PdfFormXObject CreateMacroBarcodePart(PdfDocument document, String text, float mh, float mw, int segmentId
|
||||||
|
) {
|
||||||
|
BarcodePDF417 pf = new BarcodePDF417();
|
||||||
|
// MacroPDF417 setup
|
||||||
|
pf.SetOptions(BarcodePDF417.PDF417_USE_MACRO);
|
||||||
|
pf.SetMacroFileId("12");
|
||||||
|
pf.SetMacroSegmentCount(2);
|
||||||
|
pf.SetMacroSegmentId(segmentId);
|
||||||
|
pf.SetCode(text);
|
||||||
|
return pf.CreateFormXObject(ColorConstants.BLACK, mw, mh, document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class BarcodePDF417UnitTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417CodeRowsTest() {
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCodeRows(150);
|
||||||
|
NUnit.Framework.Assert.AreEqual(150, barcode.GetCodeRows());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417CodeColumnsTest() {
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCodeColumns(150);
|
||||||
|
NUnit.Framework.Assert.AreEqual(150, barcode.GetCodeColumns());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417CodeWordsTest() {
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetLenCodewords(150);
|
||||||
|
NUnit.Framework.Assert.AreEqual(150, barcode.GetLenCodewords());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417ErrorLevelTest() {
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetErrorLevel(3);
|
||||||
|
NUnit.Framework.Assert.AreEqual(3, barcode.GetErrorLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417GetCodeWordsTest() {
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
NUnit.Framework.Assert.AreEqual(928, barcode.GetCodewords().Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417OptionsTest() {
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetOptions(100);
|
||||||
|
NUnit.Framework.Assert.AreEqual(100, barcode.GetOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode417MaxSquareTest() {
|
||||||
|
String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing "
|
||||||
|
+ "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world.";
|
||||||
|
BarcodePDF417 barcode = new BarcodePDF417();
|
||||||
|
barcode.SetCode(text);
|
||||||
|
NUnit.Framework.Assert.AreEqual(928, barcode.GetMaxSquare());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodePostnetTest : ExtendedTSpdfTest {
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/BarcodePostnet/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcodePostnet.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
BarcodePostnet codePlanet = new BarcodePostnet(document);
|
||||||
|
codePlanet.SetCode("01234567890");
|
||||||
|
codePlanet.SetCodeType(BarcodePostnet.TYPE_PLANET);
|
||||||
|
codePlanet.PlaceBarcode(canvas, null, null);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Barcodes.Qrcode;
|
||||||
|
using TSpdf.Kernel.Colors;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Kernel.Pdf.Canvas;
|
||||||
|
using TSpdf.Kernel.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("IntegrationTest")]
|
||||||
|
public class BarcodeQRCodeTest : ExtendedTSpdfTest {
|
||||||
|
public static readonly String sourceFolder = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/barcodes/";
|
||||||
|
|
||||||
|
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
|
||||||
|
+ "/test/TSpdf/barcodes/BarcodeQRCode/";
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CreateOrClearDestinationFolder(destinationFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode01Test() {
|
||||||
|
String filename = "barcodeQRCode01.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page);
|
||||||
|
IDictionary<EncodeHintType, Object> hints = new Dictionary<EncodeHintType, Object>();
|
||||||
|
hints.Put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
|
||||||
|
BarcodeQRCode barcode = new BarcodeQRCode("some specific text 239214 hello world");
|
||||||
|
barcode.PlaceBarcode(canvas, ColorConstants.GRAY, 12);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Barcode02Test() {
|
||||||
|
String filename = "barcodeQRCode02.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
PdfPage page1 = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page1);
|
||||||
|
IDictionary<EncodeHintType, Object> hints = new Dictionary<EncodeHintType, Object>();
|
||||||
|
hints.Put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||||
|
BarcodeQRCode barcode1 = new BarcodeQRCode("дима", hints);
|
||||||
|
barcode1.PlaceBarcode(canvas, ColorConstants.GRAY, 12);
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeVersioningTest() {
|
||||||
|
String filename = "barcodeQRCodeVersioning.pdf";
|
||||||
|
PdfWriter writer = new PdfWriter(destinationFolder + filename);
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
for (int i = -9; i < 42; i += 10) {
|
||||||
|
PdfPage page1 = document.AddNewPage();
|
||||||
|
PdfCanvas canvas = new PdfCanvas(page1);
|
||||||
|
IDictionary<EncodeHintType, Object> hints = new Dictionary<EncodeHintType, Object>();
|
||||||
|
hints.Put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||||
|
hints.Put(EncodeHintType.MIN_VERSION_NR, i);
|
||||||
|
BarcodeQRCode barcode1 = new BarcodeQRCode("дима", hints);
|
||||||
|
barcode1.PlaceBarcode(canvas, ColorConstants.GRAY, 3);
|
||||||
|
}
|
||||||
|
document.Close();
|
||||||
|
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + filename, sourceFolder
|
||||||
|
+ "cmp_" + filename, destinationFolder, "diff_"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.IO.Source;
|
||||||
|
using TSpdf.Kernel.Geom;
|
||||||
|
using TSpdf.Kernel.Pdf;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Barcodes {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class BarcodeUnitTest : ExtendedTSpdfTest {
|
||||||
|
private const double EPS = 0.0001;
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeMSIGetBarcodeSizeWithChecksumTest() {
|
||||||
|
PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
document.AddNewPage();
|
||||||
|
Barcode1D barcode = new BarcodeMSI(document);
|
||||||
|
document.Close();
|
||||||
|
barcode.SetCode("123456789");
|
||||||
|
barcode.SetGenerateChecksum(true);
|
||||||
|
Rectangle barcodeSize = barcode.GetBarcodeSize();
|
||||||
|
NUnit.Framework.Assert.AreEqual(33.656, barcodeSize.GetHeight(), EPS);
|
||||||
|
NUnit.Framework.Assert.AreEqual(101.6, barcodeSize.GetWidth(), EPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BarcodeMSIGetBarcodeSizeWithoutChecksumTest() {
|
||||||
|
PdfWriter writer = new PdfWriter(new ByteArrayOutputStream());
|
||||||
|
PdfDocument document = new PdfDocument(writer);
|
||||||
|
document.AddNewPage();
|
||||||
|
Barcode1D barcode = new BarcodeMSI(document);
|
||||||
|
document.Close();
|
||||||
|
barcode.SetCode("123456789");
|
||||||
|
barcode.SetGenerateChecksum(false);
|
||||||
|
Rectangle barcodeSize = barcode.GetBarcodeSize();
|
||||||
|
NUnit.Framework.Assert.AreEqual(33.656, barcodeSize.GetHeight(), EPS);
|
||||||
|
NUnit.Framework.Assert.AreEqual(92.0, barcodeSize.GetWidth(), EPS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,36 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type /Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate (D:20150910090037-03'00')/ModDate (D:20150910090037-03'00')/Producer (TSpdf<64> 6.0.0-SNAPSHOT <20>2000-2014 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont /Helvetica/Encoding /WinAnsiEncoding/Subtype /Type1/Type /Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids [4 0 R]/Type /Pages>>
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox [0 0 595 842]/Parent 2 0 R/Resources <</Font <</F1 6 0 R>>>>/TrimBox [0 0 595 842]/Type /Page>>
|
||||||
|
endobj
|
||||||
|
5 0 obj
|
||||||
|
<</Filter /FlateDecode/Length 214>>stream
|
||||||
|
x<EFBFBD><EFBFBD><EFBFBD>=<0E> <0C>wN<77><4E>.<2E>6`<60>Z<EFBFBD>=Wh*U<><55><EFBFBD>%? g<>"<22><><EFBFBD>?<3F><>,<2C>g~<1B><>1[tl)<29><>eȅ
|
||||||
|
<EFBFBD><EFBFBD><1D><><EFBFBD><EFBFBD><EFBFBD>nCҐw<D290>#<23><>z'=
|
||||||
|
S<EFBFBD>50E<>U<EFBFBD>
|
||||||
|
<EFBFBD>z<1A><>k<><6B><EFBFBD>ccݨ?tt[<01><><EFBFBD><EFBFBD>8<EFBFBD>N<12>G"}kT<6B>Yyg<79> <09>85<38>$<24><><12><0F>xT<78>r<EFBFBD><72>;<3B>D<EFBFBD><44>Q<EFBFBD>(<28>Y<EFBFBD><59>QOϬ<4F><CFAC>r<EFBFBD><72><EFBFBD>L<EFBFBD>^<5E><><EFBFBD>Vl<56><0C>?<3F>r<EFBFBD>RT<52>撓`<60><11><18>Z><3E>Q<EFBFBD><0F>ә<EFBFBD>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000322 00000 n
|
||||||
|
0000000061 00000 n
|
||||||
|
0000000375 00000 n
|
||||||
|
0000000513 00000 n
|
||||||
|
0000000230 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<97010ca3e90aa7ed96ba622194aa3e04><97010ca3e90aa7ed96ba622194aa3e04>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,37 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 1127>>stream
|
||||||
|
x<EFBFBD>U<EFBFBD>A<EFBFBD><EFBFBD>7E<>yV<79>/<2F>ER^P<>y<EFBFBD>?<3F><><16><><EFBFBD>A<EFBFBD>{!e<><01>z^<5E>z~<7E><><EFBFBD><EFBFBD><EFBFBD>z<EFBFBD><7A><EFBFBD><EFBFBD>ׯE<D7AF><45> r<><72><EFBFBD><EFBFBD><EFBFBD>|,<2C>˖u<CB96>A<EFBFBD><41>a(`;K<7F><4B>B<EFBFBD><42>?<04><><EFBFBD><EFBFBD>hp<68>iGڑ<47><02>SN<53>Ii<49><03>N<EFBFBD><4E><EFBFBD><EFBFBD>r<EFBFBD><72><EFBFBD><EFBFBD>i{Z<>V<EFBFBD>ݴ]<5D>J<EFBFBD><02>+|<7C>^\<5C>o<EFBFBD><6F> r<><72><EFBFBD><EFBFBD><EFBFBD>|,<2C>˖?<3F>l~<10><><EFBFBD>*n<><6E>=ῄ<><E1BF84><EFBFBD>ph8=<3D>p48<34>9<1E>q<EFBFBD>qNJKi<4B><69><EFBFBD><EFBFBD>Cw<43><14>Z<EFBFBD><5A><EFBFBD>V<1A>=<3D><><EFBFBD>[Kki<6B>[<5B><><EFBFBD>v\Wx=<3D><>߸'<27><>31'<27>Ğ<EFBFBD><C49E>x<>[<5B>.<2E><0C>ic<69><63><EFBFBD><11>l<>f<><1B><06><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>p<<0E>fқԧ<D29B>ƎE}1<><31>-v)<N<>i8
|
||||||
|
<EFBFBD>qn<EFBFBD><EFBFBD>¹<EFBFBD>^<5E>_ϝ<5F><CF9D><EFBFBD>{bL<sbM<62><4D>o<EFBFBD><6F><17>E<EFBFBD><45>~+<2B>ɦw㲑<77>0?We2<65>`<60>`V<><0C>3<>j<0E><>0<13><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8'<27>
|
||||||
|
f<EFBFBD>,Τ<><CEA4>ٜ̂C<D99C>o<EFBFBD>
|
||||||
|
<EFBFBD><EFBFBD>7<EFBFBD>Υ<><CEA5><EFBFBD>zz<7A><7A>7<EFBFBD><37>1<EFBFBD>L̉5<CC89>'<27><>^<5E><16><>o<EFBFBD><19><><EFBFBD>dӻq <09><><EFBFBD>#Xs<03><03><>9p<0E><>^<5E>gzN<7A>M<EFBFBD>&<26><><EFBFBD><EFBFBD>=n<>[3<><33>mΧqh.<2E>K<EFBFBD>e<EFBFBD><65>Ss%<25>qO<71><4F>gbN<62><4E>=<3D>
|
||||||
|
<17><02>(<28>\<5C><><EFBFBD>n<EFBFBD><6E><EFBFBD>p62<1B>
|
||||||
|
?܈=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43>7<EFBFBD>If%<25><><EFBFBD><EFBFBD><EFBFBD>rp(
|
||||||
|
~<7E>/<2F><><EFBFBD><02>`6̆<36>0<1B><><EFBFBD>8_8<5F>ދ<EFBFBD><DE8B>ɹZ߸'<27><>31'<27>Ğ<EFBFBD><C49E>x<>[<5B>/<2F>7<EFBFBD>7<EFBFBD><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD>^<5E><><04><>p`<1C><06><07>C<EFBFBD><43>7<EFBFBD>I<<3C><<3C>YŹ<17>b<EFBFBD><62><1E><><EFBFBD><EFBFBD>mz<1B><><1A><0B><>{<7B><><EFBFBD><EFBFBD><EFBFBD>߸'<27><>31'<27>Ğ<EFBFBD><C49E>x<>[<5B><EFBFBD>y&ӻ<><D3BB>
|
||||||
|
b<EFBFBD><EFBFBD><EFBFBD>07<EFBFBD><EFBFBD>p<><70>`<60>`<60>C<EFBFBD>a<EFBFBD><61>h<EFBFBD>O<EFBFBD>I}z~<7E>甃<E79483>P<EFBFBD><0B><>_~@<40>*<2A><05><>7<EFBFBD>ƿ<EFBFBD><C6BF><EFBFBD>j<EFBFBD>Υ<><CEA5><EFBFBD>zb<7A><62>7<EFBFBD><37>1<EFBFBD>L̉5<CC89>'<27><>^<5E><16><><EFBFBD><EFBFBD><EFBFBD>M<EFBFBD>f<EFBFBD>f<EFBFBD><66><EFBFBD><EFBFBD>v<EFBFBD>3p?<3F>|p;<3B>=<3D><>?<3F><>ޤ7qN<71><0C><>Y<EFBFBD>̂Yp
|
||||||
|
<EFBFBD>bdž<EFBFBD>pN<><4E>0<EFBFBD><30><EFBFBD>p.<2E><17>׳<EFBFBD><D7B3>|<7C><><13>ĜX{<7B>.<2E>nQ<6E><51><EFBFBD><EFBFBD>lf<06>3<>A,`z<0F>}<7D><><EFBFBD>3qH<<3C><><EFBFBD>Sԗ584ͬ<><CDAC>p<EFBFBD><70><EFBFBD>S<EFBFBD>p.<2E><><EFBFBD><EFBFBD>{<7B><><EFBFBD>c<EFBFBD><63>=1&<26><>9<EFBFBD>&<26><>7\<5C>ܢ|]<5D>㴩<EFBFBD><E3B4A9><EFBFBD><04>AMX<03><><EFBFBD>q=z[%<25>Ioz<1E><><EFBFBD>JΡ<4A>-j<><6A>f<EFBFBD>fn<66><6E>87<0E><><EFBFBD>s齜<73><E9BD9C><EFBFBD>i<EFBFBD><69>a<1E>y<17>Y<EFBFBD>Wa<1E>y<13>I<EFBFBD>a<1F>}<0F><05>7<EFBFBD><37><EFBFBD>o<EFBFBD><6F><15>sN <1F>̀y<z<0F><07><03><>I|<7C>N<><4E>3+<2B><><EFBFBD>N<>)<29><>z|<7C><>j<EFBFBD>f<>l<EFBFBD><1A><>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_x<5F>S<EFBFBD>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<<>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20200824103315+03'00')/ModDate(D:20200824103315+03'00')/Producer(TSpdf<64> 7.1.13-SNAPSHOT <20>2000-2020 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 6
|
||||||
|
0000000000 65535 f
|
||||||
|
0000001325 00000 n
|
||||||
|
0000001537 00000 n
|
||||||
|
0000001370 00000 n
|
||||||
|
0000001210 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<a91cfbafc7a05442b921b694e2313de8><a91cfbafc7a05442b921b694e2313de8>]/Info 3 0 R/Root 1 0 R/Size 6>>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,42 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 1811>>stream
|
||||||
|
x<EFBFBD>e<EFBFBD>M<EFBFBD>#5<10><><EFBFBD><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD>@<40>~<>/<18><>"̛<>3S<33><53>c
|
||||||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>W<EFBFBD><EFBFBD>ט<EFBFBD><EFBFBD><EFBFBD>W<EFBFBD>|<7C><<3C>
|
||||||
|
:-<2D><>C<EFBFBD>Ҵ4-MK<4D>Ҵ5mM[<5B>ִ5}<7D>b7<62><37>L<EFBFBD><4C>><3E><0C><18>¥<EFBFBD><C2A5><EFBFBD><EFBFBD><10>]<5D><><EFBFBD><EFBFBD>ik<69>Ca<43>,<17>nOۣ]m[<5B>-<2D><><EFBFBD>;<3B>w<EFBFBD>
|
||||||
|
<EFBFBD><EFBFBD>=<3D><><EFBFBD>ż%!\K M{<7B>i<EFBFBD>ܛ<10>}<7D>`<60><EFBFBD>|<7C>7<w&<26><>`<60>0s<30>
|
||||||
|
<EFBFBD><EFBFBD>5<EFBFBD>=<3D>el[Ɩ<><C696>%<25>%mӶik<69><6B><1B><><EFBFBD><05><><EFBFBD>
|
||||||
|
<EFBFBD>®p(<28>
|
||||||
|
<EFBFBD><EFBFBD>)<29><>9<04><>=<3D>el<19><><EFBFBD><EFBFBD>]z<<3C><><EFBFBD>[,$y<><0F>^<5E>LF<><12><><EFBFBD><EFBFBD>yCB<43>,V<16>e馔<1E>G<EFBFBD>1<EFBFBD><31>Bpq<70><71><EFBFBD><EFBFBD>vqm<71><07>{<7B>Q3y<33>/<2F><><EFBFBD>=a(9<>a<08><>[<16>5<EFBFBD><35>2<EFBFBD>L)=ڦ<>l<6C>`<60><><EFBFBD><EFBFBD><EFBFBD>7x<37><0F><><EFBFBD>%O<>s<>C0s2L)SJ<53>r<EFBFBD><72>J<EFBFBD><4A>Ql<51><6C><EFBFBD><EFBFBD>k<>=8x<38><78><EFBFBD><EFBFBD>
|
||||||
|
<EFBFBD><EFBFBD><13><><1B><><1D>
|
||||||
|
<EFBFBD><15><1D>%<25><>U<EFBFBD>J<EFBFBD><4A>2<EFBFBD><32>-c<><63>r<EFBFBD><72><EFBFBD><EFBFBD>m<>^n<><6E>mʃo>?<3F>X{r<><72>r<EFBFBD><72>c<><63>T<EFBFBD><><EEA595><EFBFBD>P0<50><30><EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD>aӶ<61><D3B6>U9Y&<17><><0E><><05><>8LF3><3E><><EFBFBD><1E><><EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD><EFBFBD>̘<EFBFBD>'|<7C><>溜*S8<19>̕<EFBFBD>0<14><><EFBFBD>X<EFBFBD>`<60>R0<52><30>mc<6D><63>v<EFBFBD><76><EFBFBD><EFBFBD>m<><6D>9&<17><><1F><><EFBFBD><EFBFBD>p*xɼ<1F><>)آ4<D8A2><34><EFBFBD>va<76>J]j[<5B>My0Ƿ<30>
|
||||||
|
><3E><1B>c<><63>v=<3D><>:u<>`<60><><EFBFBD><10>Q<EFBFBD><51><EFBFBD>-c[<5B>ִ]\/6}<7D><><EFBFBD>r<EFBFBD>Knx<6E>w<EFBFBD><77>_á<5F><C3A1>r<EFBFBD>9o<39>S)<29><15>u<EFBFBD>2wۙ3<DB99>{<7B>S<>ŵ<EFBFBD><C5B5>ZdL
|
||||||
|
.x<><0F><>o<11>%Aa<41><61>
|
||||||
|
<EFBFBD>(k<><6B><EFBFBD><EFBFBD>ܙl<>6}<7D>i0<69><30><1D><><1B><><EFBFBD>,<2C><>p(<28>K'=<3D><>e<EFBFBD><65><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><1E><>pq<70>얗<<3C><>T<EFBFBD><01><><05><><EFBFBD>p~<7E><>娠04-M<><4D>9<EFBFBD><39>К<EFBFBD>Kk<4B>=8<><38>~<7E><06><><01><>i8<69>.#<23><>Cӹ<43>!<21>R<EFBFBD><52>)<29>G<EFBFBD><47>z<EFBFBD>o<EFBFBD>S<><53><EFBFBD><EFBFBD> <20>W刓<57><E58893><06><><01><><05>K+;K[k{<0E><0E><>Mk<4D>K<EFBFBD><4B>M˦eӲiٴlZ6m<36><6D>M{<7B><>6m<36><6D>MۦmӶi<D3B6><69>yeL
|
||||||
|
<EFBFBD><EFBFBD><03><><EFBFBD>Ô<EFBFBD><C394>Cˡ<43>д4-MK<4D>Ҵ4mM[<5B>ִ5mM<6D>WH<>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD>0J<>6[<5B><>N<EFBFBD>)hZ^<5E>k<><6B><1E><>[<5B>畹4<E795B9><34>
|
||||||
|
><3E>K?
|
||||||
|
<EFBFBD><EFBFBD>C<EFBFBD><EFBFBD>l:<3A><>P
|
||||||
|
<EFBFBD><EFBFBD><EFBFBD>aѲi/K<>i<EFBFBD>Ҧ<EFBFBD>)<29>kx&<17><>|<7C><><EFBFBD><06><><EFBFBD><EFBFBD>4<EFBFBD>S<EFBFBD><53>aʼ!<21><>2<EFBFBD>\I<><49>VoM<6F><1E>+cg<63><1F> _<>
|
||||||
|
<EFBFBD><EFBFBD>u,M<><4D> <09><>)<29>bn<62>ci
|
||||||
|
<EFBFBD>`<60><>G<EFBFBD><47>rqmJk<4A>VoM<6F>ל<EFBFBD><D79C>7x<37>O<EFBFBD><4F><EFBFBD><17><><EFBFBD>)h9]<07><14><><EFBFBD><EFBFBD><EFBFBD>uNM<4E><4D>v)m<><6D>5<EFBFBD><35><EFBFBD><EFBFBD>O<EFBFBD><4F>s<> b<><62><EFBFBD><EFBFBD>:W<><57>Bk:<3A><>6M{1<><31><EFBFBD>ʡc<CAA1><1F> _<>
|
||||||
|
<EFBFBD><EFBFBD><EFBFBD>14+<2B><><0F>Ô2e<32><07>\Iiښ<69><DA9A>m<EFBFBD>ִݟ6<DD9F>y<<3C><>\<5C><01>𥟆Cǹ<43>!<21>1w7/)k<><6B>j1<6A>ڔ<>i;?!<21>
|
||||||
|
<16><>~<7E><0E><>ϭ<EFBFBD>6-~<7E>@<40><><EFBFBD><14>¡p*hZ<68><5A><EFBFBD><EFBFBD><EFBFBD>[<5B>c)ۚ<>_<EFBFBD>2i1hq<1C><><EFBFBD><EFBFBD> C<>3<EFBFBD>#<23>'<27>:9~y*<2A><><15>_<EFBFBD><5F>f5<66>W<EFBFBD>@<40><>M<02><>=<3D>L<EFBFBD>p<EFBFBD>݃<EFBFBD><EFBFBD>4<EFBFBD>"<22>"G<><7F><EFBFBD>9<EFBFBD>wr<77>a<EFBFBD><61><10>Y<EFBFBD>#7&<><7F><EFBFBD><13>Çٰ<C387>(W^O<><4F><EFBFBD>/9<18><><EFBFBD><EFBFBD>Y<EFBFBD>T<EFBFBD><54>'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{<7B><>x&މ<><DE89>
|
||||||
|
.<2E><>
|
||||||
|
&|<10><><EFBFBD>9<EFBFBD>8<EFBFBD>8<EFBFBD><38>SP<0F><>ah0<68><30><EFBFBD>k<EFBFBD><6B>_<1C>1<EFBFBD>0<EFBFBD><30>{OGOޜ_<DE9C>VVM<>LL<>U<EFBFBD>l1b<31><62><EFBFBD>5~<7E>_<EFBFBD><1D>~<7E>_<EFBFBD><5F>1<EFBFBD>pjƴ<6A>O=<3D>U<EFBFBD><55><EFBFBD><EFBFBD>Kp<4B>Lܸ<4C><0E>_<EFBFBD><17>)<29><1A><><EFBFBD><7F><EFBFBD>7<EFBFBD><37><EFBFBD>&<26><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><0B><>=<3D>L<EFBFBD>o<>[k<>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD>7<EFBFBD><37>W<EFBFBD>|<7C>9@<40>]<<12><><EFBFBD><EFBFBD>o<><6F>O<EFBFBD><4F><EFBFBD>,'e,}9<16><><EFBFBD><EFBFBD><EFBFBD>d<11><>M<EFBFBD>f=<3D><><EFBFBD><7F><EFBFBD><EFBFBD>Q>pO<<13><>g<><07><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>G3x<33><1A>_<EFBFBD>W<EFBFBD>u<>~<7E>_s}<7D><><EFBFBD><EFBFBD><EFBFBD>?u}ok<6F>j><3E>_<EFBFBD><05>AG<41>tݤ'f<><66>uF<75>Yhd<68><64><EFBFBD>FvYj<59><6A>B"{<7B><>*[U<><55>lU٪<55>Ue<55><65><EFBFBD><1B>٪<EFBFBD>u٪<75>Ug<55><67>V<EFBFBD><56>:[u<><75><EFBFBD><01><>G
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<<>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20170626115600+03'00')/ModDate(D:20170626115600+03'00')/Producer(TSpdf<64> 7.0.3-SNAPSHOT <20>2000-2017 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 6
|
||||||
Binary file not shown.
@@ -0,0 +1,39 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 365>>stream
|
||||||
|
x<EFBFBD><EFBFBD><EFBFBD>=N1<0C><><EFBFBD>"%4&q<12>i<EFBFBD><69>G<EFBFBD> i<><69><EFBFBD>I<16><><11><><EFBFBD><EFBFBD><EFBFBD>~37<33><37><1D>H`<60><><EFBFBD>?<14><>X
|
||||||
|
:<15><>5<EFBFBD><35>l<EFBFBD><EFBFBD><05><><EFBFBD><EFBFBD><EFBFBD>}<7D>p<>,<2C>#<23><>+<2B>{;vK<76><4B><19><>y <06>=5<>+<2B>-<2D><>}x,<2C>WX<57><58><EFBFBD><EFBFBD>%<25>A<EFBFBD><19><>P<>X<>YaɄ<61>9<EFBFBD><39><EFBFBD>G#<23><19><>~<7E>H<EFBFBD><48><EFBFBD>Rj<52>>xQFm<><6D><EFBFBD>z><3E>ӫլ<D3AB><D5AC><EFBFBD><EFBFBD><EFBFBD>MO<><4F><EFBFBD><EFBFBD><EFBFBD>x|5<1E>c<EFBFBD><63>(Yf<>x<EFBFBD>h<>쨡ēq<C493><71>͍Z<CD8D><5A><EFBFBD>%<25><><0F><>i^<5E>:<3A><>4y<34>Q˗<1D>Ф<EFBFBD>{<7B><><EFBFBD>y/<2F>h/<2F>zS<7A>V<EFBFBD><56>n<EFBFBD>~<7E><>)<29><><EFBFBD><0C>o4'<27><1E>#<23>^<5E>Rm<52><6D><EFBFBD><EFBFBD>\<5C>l<EFBFBD>l<EFBFBD><6C><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ݶ<><EFBFBD><7F> r<>
|
||||||
|
1<EFBFBD><EFBFBD><EFBFBD>t.2<EFBFBD>Q<EFBFBD><EFBFBD><19><><EFBFBD>!lb=<3D><0F>I)<29>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20161027110302-03'00')/ModDate(D:20161027110302-03'00')/Producer(TSpdf<64> 7.0.2-SNAPSHOT <20>2000-2016 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000580 00000 n
|
||||||
|
0000000879 00000 n
|
||||||
|
0000000625 00000 n
|
||||||
|
0000000447 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000791 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<8d020bffd1dd13b3bfc43109f092da5e><8d020bffd1dd13b3bfc43109f092da5e>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.0.2-SNAPSHOT
|
||||||
|
startxref
|
||||||
|
930
|
||||||
|
%%EOF
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type /Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate (D:20150910093355-03'00')/ModDate (D:20150910093355-03'00')/Producer (TSpdf<64> 6.0.0-SNAPSHOT <20>2000-2014 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont /Helvetica/Encoding /WinAnsiEncoding/Subtype /Type1/Type /Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids [4 0 R]/Type /Pages>>
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox [0 0 595 842]/Parent 2 0 R/Resources <</Font <</F1 6 0 R>>>>/TrimBox [0 0 595 842]/Type /Page>>
|
||||||
|
endobj
|
||||||
|
5 0 obj
|
||||||
|
<</Filter /FlateDecode/Length 262>>stream
|
||||||
|
x<EFBFBD>u<EFBFBD>An!E<><45><EFBFBD>e<EFBFBD>q<EFBFBD>cf[<5B>9Wh*E<>&<26>_&-<18>h<EFBFBD>Y<EFBFBD>o<EFBFBD><6F>o<1F><><EFBFBD>qĞA<C49E><07><1E>|;<3B><><EFBFBD><08><>1<04>H<EFBFBD><48>*<2A><><08><0F>ã<EFBFBD> <13>+<2B>F;b<1B>B<EFBFBD>p<EFBFBD><70><EFBFBD>4*<2A>`TndA<64><41><EFBFBD>G%<25>f~Ƀ<><C983>_<EFBFBD><5F><EFBFBD><EFBFBD>&Y><3E><><EFBFBD><EFBFBD><EFBFBD><15>|r6R<36>h<EFBFBD>,h<>C<EFBFBD>H><05><>4,<2C><>'1|<7C>l]͑<><02><EFBFBD>K<EFBFBD>ٗ<EFBFBD><D997><EFBFBD>%<25>le<6C><65>N<EFBFBD><4E><EFBFBD>:O@8<><38><EFBFBD><EFBFBD>APZ<50><5A><0C><><EFBFBD>5$@|3w<>J۴VOF{a<>O^<5E>yu<79><75><EFBFBD>'<27><><05>V<17><>ȤL<CDB9>ҜKh<4B>Wq<57><71>F<EFBFBD>D
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000322 00000 n
|
||||||
|
0000000061 00000 n
|
||||||
|
0000000375 00000 n
|
||||||
|
0000000513 00000 n
|
||||||
|
0000000230 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<b70c277534e03acb3192f1dd8978ab77><b70c277534e03acb3192f1dd8978ab77>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
startxref
|
||||||
|
843
|
||||||
|
%%EOF
|
||||||
Binary file not shown.
@@ -0,0 +1,37 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type /Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate (D:20150910090041-03'00')/ModDate (D:20150910090041-03'00')/Producer (TSpdf<64> 6.0.0-SNAPSHOT <20>2000-2014 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont /Helvetica/Encoding /WinAnsiEncoding/Subtype /Type1/Type /Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids [4 0 R]/Type /Pages>>
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox [0 0 595 842]/Parent 2 0 R/Resources <</Font <</F1 6 0 R>>>>/TrimBox [0 0 595 842]/Type /Page>>
|
||||||
|
endobj
|
||||||
|
5 0 obj
|
||||||
|
<</Filter /FlateDecode/Length 228>>stream
|
||||||
|
x<EFBFBD>m<EFBFBD>=n<>0<0C>w<EFBFBD><77>c3D%%<25><><EFBFBD><02> t<>$@<40>.<2E><>P<0B>k<EFBFBD><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?LLB<4C>Wbٌ8;<15><>#I<><49>Ts9K
|
||||||
|
<EFBFBD><EFBFBD>^<5E><12><><EFBFBD>U"X&<26>4<>,g<>@<40><>XW
|
||||||
|
敀<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>[<5B><>6tր<74><D680>Nrh<72><68>4
|
||||||
|
x5<EFBFBD>U<EFBFBD><EFBFBD><EFBFBD><1F><06>-<2D>m<1D>[<5B>_<0B><>*<2A><>^V<>3v<33><76>W{<7B><>ꆓqX_t<><74>dܐñ*<2A><>(<28>1<EFBFBD>?<3F>:1^G<>5<EFBFBD><35>]<5D>i>Ӓ<D392><10><><08><><EFBFBD>>T<>R<EFBFBD><52>o<><6F>r<EFBFBD><72><EFBFBD>6<EFBFBD>/<2F><><EFBFBD><EFBFBD>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000322 00000 n
|
||||||
|
0000000061 00000 n
|
||||||
|
0000000375 00000 n
|
||||||
|
0000000513 00000 n
|
||||||
|
0000000230 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<0749be85a58008bde3799e0ca9e2f720><0749be85a58008bde3799e0ca9e2f720>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
startxref
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 241>>stream
|
||||||
|
x<EFBFBD>mT1!<0C>yc<>P <20><>R<EFBFBD><02><>V<EFBFBD><56><EFBFBD><EFBFBD>?<3F>X<EFBFBD><58>t:,'<27><>"<22>|<7C><>r<1C>,<2C><>Qk<^a<>m<EFBFBD><6D><EFBFBD>CY=<3D><0E><><1D><><EFBFBD>
|
||||||
|
<EFBFBD><12><>L<EFBFBD>d<EFBFBD><64><EFBFBD><EFBFBD> Oa<4F>NU"K<><4B><11>ZkK!<<3C><> ˉ
|
||||||
|
ĭZpj<EFBFBD>ʆ<EFBFBD><EFBFBD>؋(m<><6D><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD>gk<67>"<22><04>H,<2C>h7<68>U#<23><>8mXI|<7C><>F:<3A><><EFBFBD><EFBFBD>N2<4E>I~<1D>;I<>C'<27>v<EFBFBD>Ӊσ<D389>w B\D<>@<16>>H<>%<25><><EFBFBD><EFBFBD>ĵ<EFBFBD><17>><3E><>)<29><>\<5C>z<EFBFBD><7A>W<><7F>E<EFBFBD><45>f<EFBFBD><66>u~<7E>c<EFBFBD>?ƈ<>*
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20171016093640-04'00')/ModDate(D:20171016093640-04'00')/Producer(TSpdf<64> 7.0.5-SNAPSHOT <20>2000-2017 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000456 00000 n
|
||||||
|
0000000755 00000 n
|
||||||
|
0000000501 00000 n
|
||||||
|
0000000323 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000667 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<6188289cd8ab6a0755a266864adb0cfa><6188289cd8ab6a0755a266864adb0cfa>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.0.5-SNAPSHOT
|
||||||
|
startxref
|
||||||
|
806
|
||||||
Binary file not shown.
@@ -0,0 +1,37 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 243>>stream
|
||||||
|
x<EFBFBD>mT<EFBFBD>n1<0C><><1A>ŵd[<5B><><02><17><17><05><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[<5B><>-><3E>z<EFBFBD>$ܤ<><DCA4><EFBFBD>Oi<4F><69><EFBFBD><EFBFBD><EFBFBD>bC^<5E>r<EFBFBD>.<2E><>q<EFBFBD><06><><EFBFBD>z<>^!m<>L<EFBFBD>Pa9<61><39> .b<><<3C> <09>8Ո,KrGDkW<6B><57><EFBFBD><EFBFBD><EFBFBD>ڎ<EFBFBD>$6<10>Fǩ+'<27>1<EFBFBD>Q:<3A><><EFBFBD><08>(<28>w<><77>"<22>:<04>I,<2C>hw<68>U'<27><>8<EFBFBD>XI|r#<01><><EFBFBD>$<24>A<EFBFBD><41><EFBFBD>>I<><13>'It<12>I|^$<24><11><>"J<17><><EFBFBD>E2<45><32><EFBFBD><EFBFBD>Y<EFBFBD>|<7C><>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>T<><54>F<EFBFBD>5<><35>|<7C><>1=r<><72>o<EFBFBD><6F><EFBFBD><1F>]<5D><>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20200727125207+03'00')/ModDate(D:20200727125207+03'00')/Producer(TSpdf<64> 7.1.13-SNAPSHOT <20>2000-2020 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000458 00000 n
|
||||||
|
0000000758 00000 n
|
||||||
|
0000000503 00000 n
|
||||||
|
0000000325 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000670 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<a6e21aab73bdaecd7e63e4e9a4659afa><a6e21aab73bdaecd7e63e4e9a4659afa>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.1.13-SNAPSHOT
|
||||||
|
startxref
|
||||||
|
809
|
||||||
|
%%EOF
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 243>>stream
|
||||||
|
x<EFBFBD>mT<EFBFBD>n1<0C><><1A>ŵd[<5B><><02><17><17><05><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[<5B><>-><3E>z<EFBFBD>$ܤ<><DCA4><EFBFBD>Oi<4F><69><EFBFBD><EFBFBD><EFBFBD>bC^<5E>r<EFBFBD>.<2E><>q<EFBFBD><06><><EFBFBD>z<>^!m<>L<EFBFBD>Pa9<61><39> .b<><<3C> <09>8Ո,KrGDkW<6B><57><EFBFBD><EFBFBD><EFBFBD>ڎ<EFBFBD>$6<10>Fǩ+'<27>1<EFBFBD>Q:<3A><><EFBFBD><08>(<28>w<><77>"<22>:<04>I,<2C>hw<68>U'<27><>8<EFBFBD>XI|r#<01><><EFBFBD>$<24>A<EFBFBD><41><EFBFBD>>I<><13>'It<12>I|^$<24><11><>"J<17><><EFBFBD>E2<45><32><EFBFBD><EFBFBD>Y<EFBFBD>|<7C><>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>Tq<54>3D<33><44><EFBFBD>W><3E><><EFBFBD><1E>n<EFBFBD><6E>|<7C><><0F><><EFBFBD><EFBFBD>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20200727124809+03'00')/ModDate(D:20200727124809+03'00')/Producer(TSpdf<64> 7.1.13-SNAPSHOT <20>2000-2020 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000458 00000 n
|
||||||
|
0000000758 00000 n
|
||||||
|
0000000503 00000 n
|
||||||
|
0000000325 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000670 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<7e1ca3c0337ef12256b42bb2b29c8ad9><7e1ca3c0337ef12256b42bb2b29c8ad9>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.1.13-SNAPSHOT
|
||||||
|
startxref
|
||||||
|
809
|
||||||
|
%%EOF
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,34 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 654>>stream
|
||||||
|
x<EFBFBD>m<EFBFBD>And1D<>}<7D>><3E><><EFBFBD>`><3E>@3<><33><EFBFBD><EFBFBD><18><>^F<>UCASv<53><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϗ<EFBFBD><CF97>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+.ŷ)NW|<7C>^.C<><43>H<EFBFBD>6s<(jf<>b<EFBFBD>*<2A><>#P<>n&M$<24>ٜ mE<6D>R.D)<29>D+"<22><><EFBFBD>i2<69><32>k<EFBFBD><13><>'nQB8N<38>@<40>V9<56>V)<29>#i<>S<EFBFBD>@<40>nl<12><>6ml<6D>jl<6A>jl<6A>nLlj<><C789><EFBFBD>><3E>pFl<46><6C>><3E>H<EFBFBD><48>>N<1A>c<EFBFBD><63>c<EFBFBD><63>c<EFBFBD><63>Clj^#!5<>1!I<>1!U<><55>ITcF<63>mgt<67><74>!k,s<>&<26>YM\<5C><><EFBFBD>o<EFBFBD>E<EFBFBD> <09>HѳZ<D1B3><5A><EFBFBD><07>0<1C>i
|
||||||
|
<EFBFBD><EFBFBD>#P<>o<EFBFBD>Ec/^}x<>CJ윞<4A>3=<3D>gz<67>k8J8#%<25><><10><1C><>B<04><>t<7F>:@p}<7D>J|<18>`ă<>֙Xx%J<>7t<37><74>Tt<>9<EFBFBD><39><EFBFBD>Mp<<3C><>)<29>y$P<>;<0B>L G<>n5<6E>v]h.<2E>V[ <09>yo<79>H<EFBFBD><11>(Qb<51>H<EFBFBD><48><1D>u<EFBFBD><75>m<EFBFBD>K<EFBFBD>Ľ8<C4BD><38>N<EFBFBD>`D"<22><>+<2B>S<EFBFBD>D@F<><0F>F<EFBFBD>J*D%<15>z"q<>>D<1B>X.<2E><><EFBFBD>5q
|
||||||
|
<EFBFBD><EFBFBD>2<EFBFBD>˄0d<EFBFBD><EFBFBD>,h<>I<EFBFBD>\Oxx<78>0I<10><>E<EFBFBD>\<5C><>Ɉ<><C988>I<EFBFBD><49><EFBFBD><EFBFBD><11>P<EFBFBD><50>xt<78>&<<3C>|<7C>0<13><>W<><57><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĥN<C4A5>i|y<><79>s&><3E>S<EFBFBD><12><>&<26>4 <09>$<24>y<EFBFBD>e<> 7<08>5<EFBFBD><35>v<EFBFBD>h<EFBFBD><68>DNx<4E>MX<4D><04><><EFBFBD>'.<2E><>M<EFBFBD><4D><05><><1F>C><3E><03><10><>?k0G<30>
|
||||||
|
X#<23><19><>jMx<4D>Ox&9<><39>䄵<EFBFBD><0E> v=^<5E> <0E>O<EFBFBD>TMMZ<4D>ֿ<EFBFBD>{}<><7F>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<<>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20160211114733+03'00')/ModDate(D:20160211114733+03'00')/Producer(TSpdf<64> 7.0.0-SNAPSHOT <20>2000-2016 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 6
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000851 00000 n
|
||||||
|
0000001062 00000 n
|
||||||
|
0000000896 00000 n
|
||||||
|
0000000736 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<16f7319f72fb6e6c5ab08578a37fdc9d><16f7319f72fb6e6c5ab08578a37fdc9d>]/Info 3 0 R/Root 1 0 R/Size 6>>
|
||||||
|
startxref
|
||||||
|
1113
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,38 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type /Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate (D:20150910090038-03'00')/ModDate (D:20150910090038-03'00')/Producer (TSpdf<64> 6.0.0-SNAPSHOT <20>2000-2014 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont /Helvetica/Encoding /WinAnsiEncoding/Subtype /Type1/Type /Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids [4 0 R]/Type /Pages>>
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox [0 0 595 842]/Parent 2 0 R/Resources <</Font <</F1 6 0 R>>>>/TrimBox [0 0 595 842]/Type /Page>>
|
||||||
|
endobj
|
||||||
|
5 0 obj
|
||||||
|
<</Filter /FlateDecode/Length 144>>stream
|
||||||
|
x<EFBFBD>m<EFBFBD>=<0E>0Fw<46><77>#]<5D>B<7F><42>E*'<27><15><><EFBFBD><EFBFBD><EFBFBD>RUmQ<6D><51>$/_<>3V<33><19>
|
||||||
|
j<EFBFBD><EFBFBD><13><><EFBFBD><EFBFBD>͆R<CD86><52>R#i<>JL S
|
||||||
|
L{<7B>ܢL<DCA2>[<5B>6<EFBFBD><36>S<EFBFBD>sg<73>3<><33><EFBFBD><EFBFBD><EFBFBD>ß<EFBFBD>$<24><>4<EFBFBD>Z<EFBFBD><5A>6F_<46><5F>,pw<70>><0B><02><>V;<3B><>U<EFBFBD><55><EFBFBD>p<EFBFBD>Dm<1A><05><><17><>V<EFBFBD>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000322 00000 n
|
||||||
|
0000000061 00000 n
|
||||||
|
0000000375 00000 n
|
||||||
|
0000000513 00000 n
|
||||||
|
0000000230 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<702884d86e2d6f7bccdff2d2aad40f31><702884d86e2d6f7bccdff2d2aad40f31>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
startxref
|
||||||
|
725
|
||||||
|
%%EOF
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 146>>stream
|
||||||
|
x<EFBFBD>e<EFBFBD>1<0E>0<05>ݧ<EFBFBD><08><><EFBFBD><EFBFBD>MV<4D><56><04>EBb<42><62>ȡ<>b<EFBFBD>gG<67><47><EFBFBD><EFBFBD>݁<EFBFBD><DD81>2eԈ<65>
|
||||||
|
<EFBFBD><EFBFBD>Gm<EFBFBD>Q<EFBFBD><EFBFBD>1<EFBFBD>D<EFBFBD>=*<2A>3<EFBFBD><33><EFBFBD><1E>t<EFBFBD>V<EFBFBD>V<EFBFBD>,<2C><19>
|
||||||
|
<EFBFBD>n&hʭ<68>a}<><C289><EFBFBD>#a*<2A><>`<60><>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-(%g6X<19>Lޢ
|
||||||
|
]<5D><><14>.<2E>l<EFBFBD><6C><02>uJx
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20200818002247+03'00')/ModDate(D:20200818002247+03'00')/Producer(TSpdf<64> 7.1.13-SNAPSHOT <20>2000-2020 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000361 00000 n
|
||||||
|
0000000661 00000 n
|
||||||
|
0000000406 00000 n
|
||||||
|
0000000228 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000573 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<9168b454fe1ebe383ed8914d14506d9d><9168b454fe1ebe383ed8914d14506d9d>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.1.13-SNAPSHOT
|
||||||
|
startxref
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 151>>stream
|
||||||
|
x<EFBFBD>u<EFBFBD>;1D{<7B><>%4Ɵ<34>$-<12> W`<60><>h<EFBFBD><68>,((<28><>J<13>73<37><19><><EFBFBD>0VrG<72><47><EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>2<EFBFBD>j/
|
||||||
|
;B:<3A>$w6<77><36>ԘS<D498>9<EFBFBD><39>Y
|
||||||
|
)<29><>B<EFBFBD>$<24>[<5B>M<0B>X<EFBFBD><58><EFBFBD>t,<2C><16><><05><>e9<><1C><>=<3D>J<EFBFBD><4A><EFBFBD>+$<24><><EFBFBD><EFBFBD>L<EFBFBD><4C>L)<29><><EFBFBD><EFBFBD>
|
||||||
|
<EFBFBD><EFBFBD>\<5C>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20200818002247+03'00')/ModDate(D:20200818002247+03'00')/Producer(TSpdf<64> 7.1.13-SNAPSHOT <20>2000-2020 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000366 00000 n
|
||||||
|
0000000666 00000 n
|
||||||
|
0000000411 00000 n
|
||||||
|
0000000233 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000578 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<cbc0ff563e16f5fff257fef62709af8a><cbc0ff563e16f5fff257fef62709af8a>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.1.13-SNAPSHOT
|
||||||
|
startxref
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 262>>stream
|
||||||
|
x<EFBFBD>u<EFBFBD>An<EFBFBD> E<><45><EFBFBD>e<EFBFBD>q<EFBFBD>c<><63><EFBFBD>p<><70><EFBFBD>*u3<75>_4<5F>3&<26>"E<><45><EFBFBD>'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e<><65><EFBFBD><10><><EFBFBD><17><0E>>X~<7E><>=<1E><>z<EFBFBD><7A><EFBFBD>vXz<58><7A><EFBFBD><1F><><7F>F<1C><>;L<>O(
|
||||||
|
G<<05>O0<4F><30><EFBFBD>;S<><53>U<EFBFBD><55><EFBFBD>><3E>$9<><39><13><>q<EFBFBD>g=<3D>3<EFBFBD>Q>g<>49<34><39>u<><75><EFBFBD>l<EFBFBD>y<EFBFBD>^<5E><>Y<EFBFBD><59><EFBFBD>,h<>G!cA<63>X<EFBFBD>ru<72><75>}|G/<2F>]]<5D>7<EFBFBD><37>c<EFBFBD><63>_<EFBFBD><16>ۏ<EFBFBD><DB8F> <20><><EFBFBD><EFBFBD> <09><><EFBFBD><EFBFBD>m;<3B><><EFBFBD><16><>L<1A>Z<EFBFBD>@x҅<78><D285>eѶ<13>S<EFBFBD><53>.<2E><><EFBFBD><EFBFBD><EFBFBD>j弋<6A>~2<>q<71><D7BE><03><><EFBFBD><EFBFBD>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20200818001801+03'00')/ModDate(D:20200818001801+03'00')/Producer(TSpdf<64> 7.1.13-SNAPSHOT <20>2000-2020 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000477 00000 n
|
||||||
|
0000000777 00000 n
|
||||||
|
0000000522 00000 n
|
||||||
|
0000000344 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000689 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<c63e1594aae32b64e46fcf0f9bdff8f2><c63e1594aae32b64e46fcf0f9bdff8f2>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.1.13-SNAPSHOT
|
||||||
|
startxref
|
||||||
|
828
|
||||||
|
%%EOF
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
%PDF-1.7
|
||||||
|
%<25><><EFBFBD><EFBFBD>
|
||||||
|
5 0 obj
|
||||||
|
<</Filter/FlateDecode/Length 192>>stream
|
||||||
|
x<EFBFBD>m<EFBFBD>1<0E>0E<><45><EFBFBD>#,&q<><71>]<5D><><04>EBb<42><62>ꪤnU<><55><EFBFBD>]}~<7E><><EFBFBD>c<EFBFBD> s<06>$0<>\Fbs<><73>1VB<0F>n/<2F><><EFBFBD><EFBFBD> <20>'e<><65><EFBFBD>VH<56><48>6I<36>E<>`<60><><EFBFBD>1<EFBFBD><31>ۡ<EFBFBD>Zx<03><><EFBFBD>A<EFBFBD>}<7D><><EFBFBD>{m<><6D>^<5E><>@<40><>.,<2C><>t<>~<7E><>_<EFBFBD><5F><EFBFBD><EFBFBD>L<EFBFBD><4C>V<EFBFBD><56><EFBFBD>8<EFBFBD>9<EFBFBD>l\<5C><>ɸ<>s<03>qź<71>!<21>E<EFBFBD>㤝4<17>=<3D><><01><>u<EFBFBD>
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Contents 5 0 R/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<</Font<</F1 6 0 R>>>>/TrimBox[0 0 595 842]/Type/Page>>
|
||||||
|
endobj
|
||||||
|
1 0 obj
|
||||||
|
<</Pages 2 0 R/Type/Catalog>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</CreationDate(D:20200818001802+03'00')/ModDate(D:20200818001802+03'00')/Producer(TSpdf<64> 7.1.13-SNAPSHOT <20>2000-2020 TSpdf \(1.0\))>>
|
||||||
|
endobj
|
||||||
|
6 0 obj
|
||||||
|
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Subtype/Type1/Type/Font>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Count 1/Kids[4 0 R]/Type/Pages>>
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 7
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000407 00000 n
|
||||||
|
0000000707 00000 n
|
||||||
|
0000000452 00000 n
|
||||||
|
0000000274 00000 n
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000619 00000 n
|
||||||
|
trailer
|
||||||
|
<</ID [<e379e78e88f3d98fac40c729f81c4e08><e379e78e88f3d98fac40c729f81c4e08>]/Info 3 0 R/Root 1 0 R/Size 7>>
|
||||||
|
%TSpdf-7.1.13-SNAPSHOT
|
||||||
|
startxref
|
||||||
|
758
|
||||||
|
%%EOF
|
||||||
24
TSpdf.tests/TSpdf.commons.tests/Properties/AssemblyInfo.cs
Normal file
24
TSpdf.tests/TSpdf.commons.tests/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("TSpdf.Commons.Tests")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("TSpdf")]
|
||||||
|
[assembly: AssemblyProduct("TSpdf")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright (c) 1987-2023 TSpdf")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
[assembly: Guid("502eda37-c014-4822-8e5c-4e5d21b085e9")]
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyInformationalVersion("1.0.0.0")]
|
||||||
|
|
||||||
|
#if !NETSTANDARD2_0
|
||||||
|
[assembly: NUnit.Framework.Timeout(300000)]
|
||||||
|
#endif
|
||||||
60
TSpdf.tests/TSpdf.commons.tests/TSpdf.commons.tests.csproj
Normal file
60
TSpdf.tests/TSpdf.commons.tests/TSpdf.commons.tests.csproj
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<SccProjectName>SAK</SccProjectName>
|
||||||
|
<SccProvider>SAK</SccProvider>
|
||||||
|
<SccAuxPath>SAK</SccAuxPath>
|
||||||
|
<SccLocalPath>SAK</SccLocalPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Label="Configuration">
|
||||||
|
<SignAssembly>True</SignAssembly>
|
||||||
|
<DelaySign>False</DelaySign>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netcoreapp3.1;net461;net48</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
|
||||||
|
<OutputType>library</OutputType>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<DefineConstants>NETSTANDARD2_0</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<AssemblyOriginatorKeyFile>TSpdf.snk</AssemblyOriginatorKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
<ApplicationIcon />
|
||||||
|
<OutputTypeEx>library</OutputTypeEx>
|
||||||
|
<StartupObject />
|
||||||
|
<RootNamespace />
|
||||||
|
<AssemblyName>TSpdf.commons.tests</AssemblyName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<NoWarn>1701;1702;1591;1570;1572;1573;1574;1580;1584;1658</NoWarn>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.0" />
|
||||||
|
<PackageReference Include="NUnit" Version="3.7.1" />
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\TSpdf\TSpdf.commons\TSpdf.commons.csproj" />
|
||||||
|
<ProjectReference Include="..\..\TSpdf\TSpdf.pdftest\TSpdf.pdftest.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||||
|
<Version>15.0.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation">
|
||||||
|
<Version>4.3.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
BIN
TSpdf.tests/TSpdf.commons.tests/TSpdf.snk
Normal file
BIN
TSpdf.tests/TSpdf.commons.tests/TSpdf.snk
Normal file
Binary file not shown.
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Commons.Actions.Contexts;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class AbstractContextBasedEventHandlerTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CoreEventProcessedByHandlerTest() {
|
||||||
|
AbstractContextBasedEventHandlerTest.TestEventHandler handler = new AbstractContextBasedEventHandlerTest.TestEventHandler
|
||||||
|
(UnknownContext.PERMISSIVE);
|
||||||
|
handler.OnEvent(new TSpdfTestEvent(new SequenceId(), null, "test-event", ProductNameConstant.TSpdf_CORE));
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.WasInvoked());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void AnotherProductEventNotProcessedByHandlerTest() {
|
||||||
|
AbstractContextBasedEventHandlerTest.TestEventHandler handler = new AbstractContextBasedEventHandlerTest.TestEventHandler
|
||||||
|
(UnknownContext.PERMISSIVE);
|
||||||
|
handler.OnEvent(new TSpdfTestEvent(new SequenceId(), null, "test-event", ProductNameConstant.PDF_HTML));
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.WasInvoked());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void EventWithMetaInfoTest() {
|
||||||
|
AbstractContextBasedEventHandlerTest.TestEventHandler handler = new AbstractContextBasedEventHandlerTest.TestEventHandler
|
||||||
|
(UnknownContext.PERMISSIVE);
|
||||||
|
handler.OnEvent(new TSpdfTestEvent(new SequenceId(), new TestMetaInfo("meta info from TSpdfCore"), "test-event"
|
||||||
|
, ProductNameConstant.TSpdf_CORE));
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.WasInvoked());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NotTSpdfEventIsIgnoredTest() {
|
||||||
|
AbstractContextBasedEventHandlerTest.TestEventHandler handler = new AbstractContextBasedEventHandlerTest.TestEventHandler
|
||||||
|
(UnknownContext.PERMISSIVE);
|
||||||
|
handler.OnEvent(new AbstractContextBasedEventHandlerTest.UnknownEvent());
|
||||||
|
NUnit.Framework.Assert.IsFalse(handler.WasInvoked());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestEventHandler : AbstractContextBasedEventHandler {
|
||||||
|
private bool invoked = false;
|
||||||
|
|
||||||
|
public TestEventHandler(IContext onUnknownContext)
|
||||||
|
: base(onUnknownContext) {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected internal override void OnAcceptedEvent(AbstractContextBasedTSpdfEvent @event) {
|
||||||
|
invoked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool WasInvoked() {
|
||||||
|
return invoked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UnknownEvent : IEvent {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Commons.Actions.Contexts;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class AbstractContextBasedTSpdfEventTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SetMetaInfoTest() {
|
||||||
|
AbstractContextBasedTSpdfEventTest.BasicAbstractContextBasedTSpdfEvent e = new AbstractContextBasedTSpdfEventTest.BasicAbstractContextBasedTSpdfEvent
|
||||||
|
(CommonsProductData.GetInstance(), null);
|
||||||
|
TestMetaInfo metaInfoAfter = new TestMetaInfo("meta-info-after");
|
||||||
|
e.SetMetaInfo(metaInfoAfter);
|
||||||
|
NUnit.Framework.Assert.AreSame(metaInfoAfter, e.GetMetaInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ResetMetaInfoForbiddenTest() {
|
||||||
|
TestMetaInfo metaInfoBefore = new TestMetaInfo("meta-info-before");
|
||||||
|
TestMetaInfo metaInfoAfter = new TestMetaInfo("meta-info-after");
|
||||||
|
AbstractContextBasedTSpdfEventTest.BasicAbstractContextBasedTSpdfEvent e = new AbstractContextBasedTSpdfEventTest.BasicAbstractContextBasedTSpdfEvent
|
||||||
|
(CommonsProductData.GetInstance(), metaInfoBefore);
|
||||||
|
NUnit.Framework.Assert.AreSame(metaInfoBefore, e.GetMetaInfo());
|
||||||
|
NUnit.Framework.Assert.IsFalse(e.SetMetaInfo(metaInfoAfter));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BasicAbstractContextBasedTSpdfEvent : AbstractContextBasedTSpdfEvent {
|
||||||
|
protected internal BasicAbstractContextBasedTSpdfEvent(ProductData productData, IMetaInfo metaInfo)
|
||||||
|
: base(productData, metaInfo) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class AbstractProductTSpdfEventTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullProductDataTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(InvalidOperationException), () => new _AbstractProductTSpdfEvent_36
|
||||||
|
(null));
|
||||||
|
NUnit.Framework.Assert.AreEqual("ProductData shouldn't be null.", exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class _AbstractProductTSpdfEvent_36 : AbstractProductTSpdfEvent {
|
||||||
|
public _AbstractProductTSpdfEvent_36(ProductData baseArg1)
|
||||||
|
: base(baseArg1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Logs;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using TSpdf.Test.Attributes;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class AbstractStatisticsEventTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConstructorTest() {
|
||||||
|
AbstractStatisticsEventTest.DummyStatisticsEvent dummyEvent = new AbstractStatisticsEventTest.DummyStatisticsEvent
|
||||||
|
(new ProductData("public name", "product name", "version", 15, 3000));
|
||||||
|
ProductData data = dummyEvent.GetProductData();
|
||||||
|
NUnit.Framework.Assert.AreEqual("public name", data.GetPublicProductName());
|
||||||
|
NUnit.Framework.Assert.AreEqual("product name", data.GetProductName());
|
||||||
|
NUnit.Framework.Assert.AreEqual("version", data.GetVersion());
|
||||||
|
NUnit.Framework.Assert.AreEqual(15, data.GetSinceCopyrightYear());
|
||||||
|
NUnit.Framework.Assert.AreEqual(3000, data.GetToCopyrightYear());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
[LogMessage(CommonsLogMessageConstant.INVALID_STATISTICS_NAME)]
|
||||||
|
public virtual void CreateStatisticsAggregatorFromNameTest() {
|
||||||
|
AbstractStatisticsEventTest.DummyStatisticsEvent dummyEvent = new AbstractStatisticsEventTest.DummyStatisticsEvent
|
||||||
|
(new ProductData("public name", "product name", "version", 15, 3000));
|
||||||
|
NUnit.Framework.Assert.IsNull(dummyEvent.CreateStatisticsAggregatorFromName("statisticsName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DummyStatisticsEvent : AbstractStatisticsEvent {
|
||||||
|
internal DummyStatisticsEvent(ProductData data)
|
||||||
|
: base(data) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IList<String> GetStatisticsNames() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Processors;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class AbstractTSpdfConfigurationEventTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.TearDown]
|
||||||
|
public virtual void After() {
|
||||||
|
ProductEventHandler.INSTANCE.ClearProcessors();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void AddProcessorTest() {
|
||||||
|
AbstractTSpdfConfigurationEvent @event = new AbstractTSpdfConfigurationEventTest.TestAbstractTSpdfConfigurationEvent
|
||||||
|
();
|
||||||
|
TSpdfProductEventProcessor processor = new AbstractTSpdfConfigurationEventTest.TestTSpdfProductEventProcessor
|
||||||
|
();
|
||||||
|
@event.AddProcessor(processor);
|
||||||
|
IDictionary<String, TSpdfProductEventProcessor> processors = ProductEventHandler.INSTANCE.GetProcessors();
|
||||||
|
NUnit.Framework.Assert.AreEqual(1, processors.Count);
|
||||||
|
NUnit.Framework.Assert.IsTrue(processors.Values.Contains(processor));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetProcessorsTest() {
|
||||||
|
AbstractTSpdfConfigurationEvent @event = new AbstractTSpdfConfigurationEventTest.TestAbstractTSpdfConfigurationEvent
|
||||||
|
();
|
||||||
|
TSpdfProductEventProcessor processor = new AbstractTSpdfConfigurationEventTest.TestTSpdfProductEventProcessor
|
||||||
|
();
|
||||||
|
@event.AddProcessor(processor);
|
||||||
|
NUnit.Framework.Assert.AreEqual(ProductEventHandler.INSTANCE.GetProcessors(), @event.GetProcessors());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RemoveProcessorTest() {
|
||||||
|
AbstractTSpdfConfigurationEvent @event = new AbstractTSpdfConfigurationEventTest.TestAbstractTSpdfConfigurationEvent
|
||||||
|
();
|
||||||
|
TSpdfProductEventProcessor processor = new AbstractTSpdfConfigurationEventTest.TestTSpdfProductEventProcessor
|
||||||
|
();
|
||||||
|
@event.AddProcessor(processor);
|
||||||
|
@event.RemoveProcessor(processor.GetProductName());
|
||||||
|
IDictionary<String, TSpdfProductEventProcessor> processors = ProductEventHandler.INSTANCE.GetProcessors();
|
||||||
|
NUnit.Framework.Assert.AreEqual(0, processors.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetActiveProcessorTest() {
|
||||||
|
AbstractTSpdfConfigurationEvent @event = new AbstractTSpdfConfigurationEventTest.TestAbstractTSpdfConfigurationEvent
|
||||||
|
();
|
||||||
|
TSpdfProductEventProcessor processor = new AbstractTSpdfConfigurationEventTest.TestTSpdfProductEventProcessor
|
||||||
|
();
|
||||||
|
@event.AddProcessor(processor);
|
||||||
|
NUnit.Framework.Assert.AreEqual(processor, @event.GetActiveProcessor(processor.GetProductName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void AddEventTest() {
|
||||||
|
AbstractTSpdfConfigurationEvent configurationEvent = new AbstractTSpdfConfigurationEventTest.TestAbstractTSpdfConfigurationEvent
|
||||||
|
();
|
||||||
|
AbstractProductProcessTSpdfEvent processEvent = new AbstractTSpdfConfigurationEventTest.TestAbstractProductProcessTSpdfEvent
|
||||||
|
();
|
||||||
|
SequenceId id = new SequenceId();
|
||||||
|
configurationEvent.AddEvent(id, processEvent);
|
||||||
|
IList<AbstractProductProcessTSpdfEvent> events = ProductEventHandler.INSTANCE.GetEvents(id);
|
||||||
|
NUnit.Framework.Assert.AreEqual(1, events.Count);
|
||||||
|
NUnit.Framework.Assert.AreEqual(processEvent, events[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetEventsTest() {
|
||||||
|
AbstractTSpdfConfigurationEvent configurationEvent = new AbstractTSpdfConfigurationEventTest.TestAbstractTSpdfConfigurationEvent
|
||||||
|
();
|
||||||
|
SequenceId id = new SequenceId();
|
||||||
|
configurationEvent.AddEvent(id, new AbstractTSpdfConfigurationEventTest.TestAbstractProductProcessTSpdfEvent
|
||||||
|
());
|
||||||
|
configurationEvent.AddEvent(id, new AbstractTSpdfConfigurationEventTest.TestAbstractProductProcessTSpdfEvent
|
||||||
|
());
|
||||||
|
NUnit.Framework.Assert.AreEqual(ProductEventHandler.INSTANCE.GetEvents(id), configurationEvent.GetEvents(id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class TestAbstractTSpdfConfigurationEvent : AbstractTSpdfConfigurationEvent {
|
||||||
|
protected internal override void DoAction() {
|
||||||
|
}
|
||||||
|
// Empty method.
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class TestAbstractProductProcessTSpdfEvent : AbstractProductProcessTSpdfEvent {
|
||||||
|
public TestAbstractProductProcessTSpdfEvent()
|
||||||
|
: base(new SequenceId(), new ProductData("test public product name", "test product name", "test version",
|
||||||
|
0, 1), null, EventConfirmationType.ON_DEMAND) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public override String GetEventType() {
|
||||||
|
return "test event type";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class TestTSpdfProductEventProcessor : TSpdfProductEventProcessor {
|
||||||
|
public virtual void OnEvent(AbstractProductProcessTSpdfEvent @event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty method.
|
||||||
|
public virtual String GetProductName() {
|
||||||
|
return "test product";
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual String GetUsageType() {
|
||||||
|
return "test usage type";
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual String GetProducer() {
|
||||||
|
return "test producer";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions.Processors;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Commons.Exceptions;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using TSpdf.Test.Attributes;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class EventManagerTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.TearDown]
|
||||||
|
public virtual void AfterEach() {
|
||||||
|
ProductProcessorFactoryKeeper.RestoreDefaultProductProcessorFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
[LogMessage(TestConfigurationEvent.MESSAGE)]
|
||||||
|
public virtual void ConfigurationEventTest() {
|
||||||
|
NUnit.Framework.Assert.DoesNotThrow(() => EventManager.GetInstance().OnEvent(new TestConfigurationEvent())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ThrowSomeExceptionsTest() {
|
||||||
|
EventManager eventManager = EventManager.GetInstance();
|
||||||
|
IEventHandler handler1 = new EventManagerTest.ThrowArithmeticExpHandler();
|
||||||
|
IEventHandler handler2 = new EventManagerTest.ThrowIllegalArgumentExpHandler();
|
||||||
|
eventManager.Register(handler1);
|
||||||
|
eventManager.Register(handler2);
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
try {
|
||||||
|
eventManager.OnEvent(new TSpdfTestEvent(sequenceId, null, "test-event", ProductNameConstant.TSpdf_CORE));
|
||||||
|
}
|
||||||
|
catch (AggregatedException e) {
|
||||||
|
NUnit.Framework.Assert.AreEqual("Error during event processing:\n" + "0) ThrowArithmeticExpHandler\n" + "1) ThrowIllegalArgumentExpHandler\n"
|
||||||
|
, e.Message);
|
||||||
|
IList<Exception> aggregatedExceptions = e.GetAggregatedExceptions();
|
||||||
|
NUnit.Framework.Assert.AreEqual(2, aggregatedExceptions.Count);
|
||||||
|
NUnit.Framework.Assert.AreEqual("ThrowArithmeticExpHandler", aggregatedExceptions[0].Message);
|
||||||
|
NUnit.Framework.Assert.AreEqual("ThrowIllegalArgumentExpHandler", aggregatedExceptions[1].Message);
|
||||||
|
}
|
||||||
|
eventManager.Unregister(handler1);
|
||||||
|
eventManager.Unregister(handler2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ThrowOneUncheckedExceptionsTest() {
|
||||||
|
EventManager eventManager = EventManager.GetInstance();
|
||||||
|
IEventHandler handler1 = new EventManagerTest.ThrowArithmeticExpHandler();
|
||||||
|
eventManager.Register(handler1);
|
||||||
|
try {
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArithmeticException), () => eventManager.OnEvent
|
||||||
|
(new TSpdfTestEvent(sequenceId, null, "test-event", ProductNameConstant.TSpdf_CORE)));
|
||||||
|
NUnit.Framework.Assert.AreEqual("ThrowArithmeticExpHandler", exception.Message);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
eventManager.Unregister(handler1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConfigureHandlersTest() {
|
||||||
|
EventManager eventManager = EventManager.GetInstance();
|
||||||
|
IEventHandler handler = new EventManagerTest.ThrowArithmeticExpHandler();
|
||||||
|
NUnit.Framework.Assert.IsFalse(eventManager.IsRegistered(handler));
|
||||||
|
eventManager.Register(handler);
|
||||||
|
NUnit.Framework.Assert.IsTrue(eventManager.IsRegistered(handler));
|
||||||
|
NUnit.Framework.Assert.IsTrue(eventManager.Unregister(handler));
|
||||||
|
NUnit.Framework.Assert.IsFalse(eventManager.IsRegistered(handler));
|
||||||
|
NUnit.Framework.Assert.IsFalse(eventManager.Unregister(handler));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TurningOffAgplTest() {
|
||||||
|
IProductProcessorFactory defaultProductProcessorFactory = ProductProcessorFactoryKeeper.GetProductProcessorFactory
|
||||||
|
();
|
||||||
|
NUnit.Framework.Assert.IsTrue(defaultProductProcessorFactory is DefaultProductProcessorFactory);
|
||||||
|
EventManager.AcknowledgeAgplUsageDisableWarningMessage();
|
||||||
|
IProductProcessorFactory underAgplProductProcessorFactory1 = ProductProcessorFactoryKeeper.GetProductProcessorFactory
|
||||||
|
();
|
||||||
|
NUnit.Framework.Assert.IsTrue(underAgplProductProcessorFactory1 is UnderAgplProductProcessorFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ThrowArithmeticExpHandler : IEventHandler {
|
||||||
|
public virtual void OnEvent(IEvent @event) {
|
||||||
|
throw new ArithmeticException("ThrowArithmeticExpHandler");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ThrowIllegalArgumentExpHandler : IEventHandler {
|
||||||
|
public virtual void OnEvent(IEvent @event) {
|
||||||
|
throw new ArgumentException("ThrowIllegalArgumentExpHandler");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System.IO;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
public class ProductEventHandlerIntegrationTest : ExtendedTSpdfTest {
|
||||||
|
private TextWriter outBackup;
|
||||||
|
|
||||||
|
[NUnit.Framework.SetUp]
|
||||||
|
public virtual void InitTest() {
|
||||||
|
outBackup = System.Console.Out;
|
||||||
|
ProductEventHandler.INSTANCE.ClearProcessors();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TearDown]
|
||||||
|
public virtual void AfterEach() {
|
||||||
|
System.Console.SetOut(outBackup);
|
||||||
|
ProductProcessorFactoryKeeper.RestoreDefaultProductProcessorFactory();
|
||||||
|
ProductEventHandler.INSTANCE.ClearProcessors();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RemoveAGPLLoggingTest() {
|
||||||
|
MemoryStream testOut = new MemoryStream();
|
||||||
|
System.Console.SetOut(new FormattingStreamWriter(testOut));
|
||||||
|
|
||||||
|
EventManager.AcknowledgeAgplUsageDisableWarningMessage();
|
||||||
|
for (int i = 0; i < 10001; i++) {
|
||||||
|
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId).IsEmpty());
|
||||||
|
TSpdfTestEvent @event = new TSpdfTestEvent(sequenceId, null, "test-event",
|
||||||
|
ProductNameConstant.TSpdf_CORE);
|
||||||
|
EventManager.GetInstance().OnEvent(@event);
|
||||||
|
|
||||||
|
ConfirmEvent confirmEvent = new ConfirmEvent(sequenceId, @event);
|
||||||
|
EventManager.GetInstance().OnEvent(confirmEvent);
|
||||||
|
|
||||||
|
NUnit.Framework.Assert.AreEqual(1, handler.GetEvents(sequenceId).Count);
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId)[0] is ConfirmedEventWrapper);
|
||||||
|
NUnit.Framework.Assert.AreEqual(@event, ((ConfirmedEventWrapper)handler.GetEvents(sequenceId)[0]).GetEvent
|
||||||
|
());
|
||||||
|
}
|
||||||
|
using (var reader = new StreamReader(testOut))
|
||||||
|
{
|
||||||
|
NUnit.Framework.Assert.AreEqual("", reader.ReadToEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Processors;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Commons.Exceptions;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class ProductEventHandlerTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.SetUp]
|
||||||
|
public virtual void ClearProcessors() {
|
||||||
|
ProductEventHandler.INSTANCE.ClearProcessors();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TearDown]
|
||||||
|
public virtual void AfterEach() {
|
||||||
|
ProductProcessorFactoryKeeper.RestoreDefaultProductProcessorFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UnknownProductTest() {
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
AbstractContextBasedTSpdfEvent @event = new TSpdfTestEvent(new SequenceId(), null, "test-event", "Unknown Product"
|
||||||
|
);
|
||||||
|
Exception ex = NUnit.Framework.Assert.Catch(typeof(UnknownProductException), () => handler.OnAcceptedEvent
|
||||||
|
(@event));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(UnknownProductException.UNKNOWN_PRODUCT, "Unknown Product"
|
||||||
|
), ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SequenceIdBasedEventTest() {
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId).IsEmpty());
|
||||||
|
handler.OnAcceptedEvent(new TSpdfTestEvent(sequenceId, null, "test-event", ProductNameConstant.TSpdf_CORE)
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.AreEqual(1, handler.GetEvents(sequenceId).Count);
|
||||||
|
AbstractProductProcessTSpdfEvent @event = handler.GetEvents(sequenceId)[0];
|
||||||
|
NUnit.Framework.Assert.AreEqual(sequenceId.GetId(), @event.GetSequenceId().GetId());
|
||||||
|
NUnit.Framework.Assert.IsNull(@event.GetMetaInfo());
|
||||||
|
NUnit.Framework.Assert.AreEqual("test-event", @event.GetEventType());
|
||||||
|
NUnit.Framework.Assert.AreEqual(ProductNameConstant.TSpdf_CORE, @event.GetProductName());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ReportEventSeveralTimesTest() {
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId).IsEmpty());
|
||||||
|
TSpdfTestEvent @event = new TSpdfTestEvent(sequenceId, null, "test-event", ProductNameConstant.TSpdf_CORE);
|
||||||
|
EventManager.GetInstance().OnEvent(@event);
|
||||||
|
NUnit.Framework.Assert.AreEqual(1, handler.GetEvents(sequenceId).Count);
|
||||||
|
NUnit.Framework.Assert.AreEqual(@event, handler.GetEvents(sequenceId)[0]);
|
||||||
|
EventManager.GetInstance().OnEvent(@event);
|
||||||
|
NUnit.Framework.Assert.AreEqual(2, handler.GetEvents(sequenceId).Count);
|
||||||
|
NUnit.Framework.Assert.AreEqual(@event, handler.GetEvents(sequenceId)[0]);
|
||||||
|
NUnit.Framework.Assert.AreEqual(@event, handler.GetEvents(sequenceId)[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConfirmEventTest() {
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId).IsEmpty());
|
||||||
|
TSpdfTestEvent @event = new TSpdfTestEvent(sequenceId, null, "test-event", ProductNameConstant.TSpdf_CORE);
|
||||||
|
EventManager.GetInstance().OnEvent(@event);
|
||||||
|
ConfirmEvent confirmEvent = new ConfirmEvent(sequenceId, @event);
|
||||||
|
EventManager.GetInstance().OnEvent(confirmEvent);
|
||||||
|
NUnit.Framework.Assert.AreEqual(1, handler.GetEvents(sequenceId).Count);
|
||||||
|
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId)[0] is ConfirmedEventWrapper);
|
||||||
|
NUnit.Framework.Assert.AreEqual(@event, ((ConfirmedEventWrapper)handler.GetEvents(sequenceId)[0]).GetEvent
|
||||||
|
());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SettingCustomProcessFactoryTest() {
|
||||||
|
ProductEventHandlerTest.CustomFactory productProcessorFactory = new ProductEventHandlerTest.CustomFactory(
|
||||||
|
);
|
||||||
|
productProcessorFactory.CreateProcessor(ProductNameConstant.TSpdf_CORE);
|
||||||
|
ProductProcessorFactoryKeeper.SetProductProcessorFactory(productProcessorFactory);
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
TSpdfProductEventProcessor activeProcessor = handler.GetActiveProcessor(ProductNameConstant.TSpdf_CORE);
|
||||||
|
NUnit.Framework.Assert.IsTrue(activeProcessor is ProductEventHandlerTest.TestProductEventProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RepeatEventHandlingWithFiveExceptionOnProcessingTest() {
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
handler.AddProcessor(new ProductEventHandlerTest.RepeatEventProcessor(5));
|
||||||
|
AbstractContextBasedTSpdfEvent @event = new TSpdfTestEvent(new SequenceId(), null, "test", ProductNameConstant
|
||||||
|
.TSpdf_CORE);
|
||||||
|
Exception e = NUnit.Framework.Assert.Catch(typeof(ProductEventHandlerRepeatException), () => handler.OnAcceptedEvent
|
||||||
|
(@event));
|
||||||
|
NUnit.Framework.Assert.AreEqual("customMessage5", e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RepeatEventHandlingWithFourExceptionOnProcessingTest() {
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
handler.AddProcessor(new ProductEventHandlerTest.RepeatEventProcessor(4));
|
||||||
|
AbstractContextBasedTSpdfEvent @event = new TSpdfTestEvent(new SequenceId(), null, "test", ProductNameConstant
|
||||||
|
.TSpdf_CORE);
|
||||||
|
NUnit.Framework.Assert.DoesNotThrow(() => handler.OnAcceptedEvent(@event));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RepeatEventHandlingWithOneExceptionOnProcessingTest() {
|
||||||
|
ProductEventHandler handler = ProductEventHandler.INSTANCE;
|
||||||
|
handler.AddProcessor(new ProductEventHandlerTest.RepeatEventProcessor(1));
|
||||||
|
AbstractContextBasedTSpdfEvent @event = new TSpdfTestEvent(new SequenceId(), null, "test", ProductNameConstant
|
||||||
|
.TSpdf_CORE);
|
||||||
|
NUnit.Framework.Assert.DoesNotThrow(() => handler.OnAcceptedEvent(@event));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CustomFactory : IProductProcessorFactory {
|
||||||
|
public virtual TSpdfProductEventProcessor CreateProcessor(String productName) {
|
||||||
|
return new ProductEventHandlerTest.TestProductEventProcessor(productName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestProductEventProcessor : AbstractTSpdfProductEventProcessor {
|
||||||
|
public TestProductEventProcessor(String productName)
|
||||||
|
: base(productName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnEvent(AbstractProductProcessTSpdfEvent @event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// do nothing
|
||||||
|
public override String GetUsageType() {
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RepeatEventProcessor : TSpdfProductEventProcessor {
|
||||||
|
private readonly int exceptionsCount;
|
||||||
|
|
||||||
|
private int exceptionCounter = 0;
|
||||||
|
|
||||||
|
public RepeatEventProcessor(int exceptionsCount) {
|
||||||
|
this.exceptionsCount = exceptionsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnEvent(AbstractProductProcessTSpdfEvent @event) {
|
||||||
|
if (exceptionCounter < exceptionsCount) {
|
||||||
|
exceptionCounter++;
|
||||||
|
throw new ProductEventHandlerRepeatException("customMessage" + exceptionCounter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual String GetProductName() {
|
||||||
|
return ProductNameConstant.TSpdf_CORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual String GetUsageType() {
|
||||||
|
return "someUsage";
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual String GetProducer() {
|
||||||
|
return "someProducer";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Commons.Actions.Processors;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class ProductProcessorFactoryKeeperTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.TearDown]
|
||||||
|
public virtual void AfterEach() {
|
||||||
|
ProductProcessorFactoryKeeper.RestoreDefaultProductProcessorFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GettingDefaultFactoryFromKeeper() {
|
||||||
|
IProductProcessorFactory productProcessorFactory = ProductProcessorFactoryKeeper.GetProductProcessorFactory
|
||||||
|
();
|
||||||
|
NUnit.Framework.Assert.IsTrue(productProcessorFactory is DefaultProductProcessorFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RestoringDefaultFactory() {
|
||||||
|
ProductProcessorFactoryKeeper.SetProductProcessorFactory(new UnderAgplProductProcessorFactory());
|
||||||
|
NUnit.Framework.Assert.IsTrue(ProductProcessorFactoryKeeper.GetProductProcessorFactory() is UnderAgplProductProcessorFactory
|
||||||
|
);
|
||||||
|
ProductProcessorFactoryKeeper.RestoreDefaultProductProcessorFactory();
|
||||||
|
NUnit.Framework.Assert.IsTrue(ProductProcessorFactoryKeeper.GetProductProcessorFactory() is DefaultProductProcessorFactory
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Confirmations {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class ConfirmEventTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConstructorWithSequenceIdTest() {
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
TSpdfTestEvent TSpdfTestEvent = new TSpdfTestEvent(new SequenceId(), new TestMetaInfo(""), "eventType", "productName"
|
||||||
|
);
|
||||||
|
ConfirmEvent confirmEvent = new ConfirmEvent(sequenceId, TSpdfTestEvent);
|
||||||
|
NUnit.Framework.Assert.AreSame(TSpdfTestEvent, confirmEvent.GetConfirmedEvent());
|
||||||
|
NUnit.Framework.Assert.AreEqual("eventType", confirmEvent.GetEventType());
|
||||||
|
NUnit.Framework.Assert.AreEqual("productName", confirmEvent.GetProductName());
|
||||||
|
NUnit.Framework.Assert.AreSame(sequenceId, confirmEvent.GetSequenceId());
|
||||||
|
NUnit.Framework.Assert.AreEqual(EventConfirmationType.UNCONFIRMABLE, confirmEvent.GetConfirmationType());
|
||||||
|
NUnit.Framework.Assert.IsNotNull(confirmEvent.GetProductData());
|
||||||
|
NUnit.Framework.Assert.AreEqual(typeof(TSpdfTestEvent), confirmEvent.GetClassFromContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConstructorWithoutSequenceIdTest() {
|
||||||
|
TSpdfTestEvent TSpdfTestEvent = new TSpdfTestEvent(new SequenceId(), new TestMetaInfo(""), "eventType", "productName"
|
||||||
|
);
|
||||||
|
ConfirmEvent confirmEvent = new ConfirmEvent(TSpdfTestEvent);
|
||||||
|
NUnit.Framework.Assert.AreSame(TSpdfTestEvent, confirmEvent.GetConfirmedEvent());
|
||||||
|
NUnit.Framework.Assert.AreEqual("eventType", confirmEvent.GetEventType());
|
||||||
|
NUnit.Framework.Assert.AreEqual("productName", confirmEvent.GetProductName());
|
||||||
|
NUnit.Framework.Assert.AreSame(TSpdfTestEvent.GetSequenceId(), confirmEvent.GetSequenceId());
|
||||||
|
NUnit.Framework.Assert.AreEqual(EventConfirmationType.UNCONFIRMABLE, confirmEvent.GetConfirmationType());
|
||||||
|
NUnit.Framework.Assert.IsNotNull(confirmEvent.GetProductData());
|
||||||
|
NUnit.Framework.Assert.AreEqual(typeof(TSpdfTestEvent), confirmEvent.GetClassFromContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConfirmEventInsideOtherConfirmEventTest() {
|
||||||
|
TSpdfTestEvent TSpdfTestEvent = new TSpdfTestEvent(new SequenceId(), new TestMetaInfo(""), "eventType", "productName"
|
||||||
|
);
|
||||||
|
ConfirmEvent child = new ConfirmEvent(TSpdfTestEvent.GetSequenceId(), TSpdfTestEvent);
|
||||||
|
ConfirmEvent confirmEvent = new ConfirmEvent(child);
|
||||||
|
NUnit.Framework.Assert.AreSame(TSpdfTestEvent, confirmEvent.GetConfirmedEvent());
|
||||||
|
NUnit.Framework.Assert.AreSame(TSpdfTestEvent, confirmEvent.GetConfirmedEvent());
|
||||||
|
NUnit.Framework.Assert.AreEqual("eventType", confirmEvent.GetEventType());
|
||||||
|
NUnit.Framework.Assert.AreEqual("productName", confirmEvent.GetProductName());
|
||||||
|
NUnit.Framework.Assert.AreSame(TSpdfTestEvent.GetSequenceId(), confirmEvent.GetSequenceId());
|
||||||
|
NUnit.Framework.Assert.AreEqual(EventConfirmationType.UNCONFIRMABLE, confirmEvent.GetConfirmationType());
|
||||||
|
NUnit.Framework.Assert.IsNotNull(confirmEvent.GetProductData());
|
||||||
|
NUnit.Framework.Assert.AreEqual(typeof(TSpdfTestEvent), confirmEvent.GetClassFromContext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Contexts {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class ContextManagerTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetRecognisedNamespaceForSpecificNamespaceTest() {
|
||||||
|
String outerNamespaces = NamespaceConstant.TSpdf.ToLowerInvariant();
|
||||||
|
String innerNamespaces = NamespaceConstant.PDF_HTML.ToLowerInvariant();
|
||||||
|
NUnit.Framework.Assert.IsTrue(innerNamespaces.StartsWith(outerNamespaces));
|
||||||
|
ContextManager managerOuterBeforeInner = new ContextManager();
|
||||||
|
managerOuterBeforeInner.RegisterGenericContext(JavaCollectionsUtil.SingletonList(outerNamespaces), JavaCollectionsUtil
|
||||||
|
.EmptyList<String>());
|
||||||
|
managerOuterBeforeInner.RegisterGenericContext(JavaCollectionsUtil.SingletonList(innerNamespaces), JavaCollectionsUtil
|
||||||
|
.EmptyList<String>());
|
||||||
|
NUnit.Framework.Assert.AreEqual(outerNamespaces, managerOuterBeforeInner.GetRecognisedNamespace(outerNamespaces
|
||||||
|
));
|
||||||
|
NUnit.Framework.Assert.AreEqual(innerNamespaces, managerOuterBeforeInner.GetRecognisedNamespace(innerNamespaces
|
||||||
|
));
|
||||||
|
ContextManager managerInnerBeforeOuter = new ContextManager();
|
||||||
|
managerInnerBeforeOuter.RegisterGenericContext(JavaCollectionsUtil.SingletonList(innerNamespaces), JavaCollectionsUtil
|
||||||
|
.EmptyList<String>());
|
||||||
|
managerInnerBeforeOuter.RegisterGenericContext(JavaCollectionsUtil.SingletonList(outerNamespaces), JavaCollectionsUtil
|
||||||
|
.EmptyList<String>());
|
||||||
|
NUnit.Framework.Assert.AreEqual(outerNamespaces, managerInnerBeforeOuter.GetRecognisedNamespace(outerNamespaces
|
||||||
|
));
|
||||||
|
NUnit.Framework.Assert.AreEqual(innerNamespaces, managerInnerBeforeOuter.GetRecognisedNamespace(innerNamespaces
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NotRegisteredNamespaceTest() {
|
||||||
|
String notRegisteredNamespace = "com.hello.world";
|
||||||
|
NUnit.Framework.Assert.IsNull(ContextManager.GetInstance().GetRecognisedNamespace(notRegisteredNamespace));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UnregisterNamespaceTest() {
|
||||||
|
String testNamespace = "com.hello.world";
|
||||||
|
String testNamespaceWithCapitals = "com.Bye.World";
|
||||||
|
IList<String> testNamespaces = JavaUtil.ArraysAsList(testNamespace, testNamespaceWithCapitals);
|
||||||
|
ContextManager manager = new ContextManager();
|
||||||
|
NUnit.Framework.Assert.IsNull(manager.GetRecognisedNamespace(testNamespace));
|
||||||
|
NUnit.Framework.Assert.IsNull(manager.GetRecognisedNamespace(testNamespaceWithCapitals));
|
||||||
|
manager.RegisterGenericContext(testNamespaces, JavaUtil.ArraysAsList("myProduct"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(testNamespace, manager.GetRecognisedNamespace(testNamespace + ".MyClass"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(testNamespaceWithCapitals.ToLowerInvariant(), manager.GetRecognisedNamespace
|
||||||
|
(testNamespaceWithCapitals + ".MyClass"));
|
||||||
|
manager.UnregisterContext(testNamespaces);
|
||||||
|
NUnit.Framework.Assert.IsNull(manager.GetRecognisedNamespace(testNamespace));
|
||||||
|
NUnit.Framework.Assert.IsNull(manager.GetRecognisedNamespace(testNamespaceWithCapitals));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RegisteredNamespaceTest() {
|
||||||
|
String registeredNamespace = NamespaceConstant.CORE_LAYOUT + "custompackage";
|
||||||
|
NUnit.Framework.Assert.AreEqual(NamespaceConstant.CORE_LAYOUT.ToLowerInvariant(), ContextManager.GetInstance
|
||||||
|
().GetRecognisedNamespace(registeredNamespace));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Data {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class CommonsProductDataTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetInstanceTest() {
|
||||||
|
ProductData commonsProductData = CommonsProductData.GetInstance();
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsProductData.COMMONS_PUBLIC_PRODUCT_NAME, commonsProductData.GetPublicProductName
|
||||||
|
());
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsProductData.COMMONS_PRODUCT_NAME, commonsProductData.GetProductName
|
||||||
|
());
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsProductData.COMMONS_VERSION, commonsProductData.GetVersion());
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsProductData.COMMONS_COPYRIGHT_SINCE, commonsProductData.GetSinceCopyrightYear
|
||||||
|
());
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsProductData.COMMONS_COPYRIGHT_TO, commonsProductData.GetToCopyrightYear
|
||||||
|
());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Data {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class ProductDataTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ProductDataCreationTest() {
|
||||||
|
ProductData productData = new ProductData("publicProductName", "productName", "1.2", 1900, 2100);
|
||||||
|
NUnit.Framework.Assert.AreEqual("publicProductName", productData.GetPublicProductName());
|
||||||
|
NUnit.Framework.Assert.AreEqual("productName", productData.GetProductName());
|
||||||
|
NUnit.Framework.Assert.AreEqual("1.2", productData.GetVersion());
|
||||||
|
NUnit.Framework.Assert.AreEqual(1900, productData.GetSinceCopyrightYear());
|
||||||
|
NUnit.Framework.Assert.AreEqual(2100, productData.GetToCopyrightYear());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ProductDataAnotherCreationTest() {
|
||||||
|
ProductData productData = new ProductData("publicProductName", "productName", "1.2", "4.0.0", 1900, 2100);
|
||||||
|
NUnit.Framework.Assert.AreEqual("publicProductName", productData.GetPublicProductName());
|
||||||
|
NUnit.Framework.Assert.AreEqual("productName", productData.GetProductName());
|
||||||
|
NUnit.Framework.Assert.AreEqual("1.2", productData.GetVersion());
|
||||||
|
NUnit.Framework.Assert.AreEqual("4.0.0", productData.GetMinCompatibleLicensingModuleVersion());
|
||||||
|
NUnit.Framework.Assert.AreEqual(1900, productData.GetSinceCopyrightYear());
|
||||||
|
NUnit.Framework.Assert.AreEqual(2100, productData.GetToCopyrightYear());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void EqualsTest() {
|
||||||
|
ProductData a = new ProductData("publicProductName", "productName", "1.2", 1900, 2100);
|
||||||
|
ProductData b = new ProductData("publicProductName", "productName", "1.2", 1900, 2100);
|
||||||
|
NUnit.Framework.Assert.AreEqual(a, a);
|
||||||
|
NUnit.Framework.Assert.AreEqual(a, b);
|
||||||
|
NUnit.Framework.Assert.AreEqual(b, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NotEqualsTest() {
|
||||||
|
ProductData a = new ProductData("publicProductName", "productName", "1.2", 1900, 2100);
|
||||||
|
ProductData d = new ProductData("publicProductName", "productName", "1.2", 1910, 2110);
|
||||||
|
NUnit.Framework.Assert.AreNotEqual(a, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void HashCodeTest() {
|
||||||
|
ProductData a = new ProductData("publicProductName", "productName", "1.2", 1900, 2100);
|
||||||
|
ProductData b = new ProductData("publicProductName", "productName", "1.2", 1900, 2100);
|
||||||
|
NUnit.Framework.Assert.AreEqual(a, b);
|
||||||
|
NUnit.Framework.Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
|
||||||
|
int h1 = a.GetHashCode();
|
||||||
|
int h2 = a.GetHashCode();
|
||||||
|
NUnit.Framework.Assert.AreEqual(h1, h2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Commons.Actions;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Processors {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class DefaultProductProcessorFactoryTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CreateDefaultProductProcessor() {
|
||||||
|
DefaultProductProcessorFactory defaultProductProcessorFactory = new DefaultProductProcessorFactory();
|
||||||
|
TSpdfProductEventProcessor processor = defaultProductProcessorFactory.CreateProcessor(ProductNameConstant.
|
||||||
|
TSpdf_CORE);
|
||||||
|
NUnit.Framework.Assert.IsNotNull(processor);
|
||||||
|
NUnit.Framework.Assert.IsTrue(processor is DefaultTSpdfProductEventProcessor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Commons.Exceptions;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using TSpdf.Test.Attributes;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Processors {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class DefaultTSpdfProductEventProcessorTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ConstructorWithNullProductNameTest() {
|
||||||
|
Exception e = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => new DefaultTSpdfProductEventProcessor
|
||||||
|
(null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.PRODUCT_NAME_CAN_NOT_BE_NULL, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
[LogMessage("{0} you are probably {1}", LogLevel = LogLevelConstants.INFO)]
|
||||||
|
public virtual void MessageIsLoggedTest() {
|
||||||
|
DefaultTSpdfProductEventProcessorTest.TestDefaultTSpdfProductEventProcessor testProcessor = new DefaultTSpdfProductEventProcessorTest.TestDefaultTSpdfProductEventProcessor
|
||||||
|
();
|
||||||
|
TSpdfTestEvent e = new TSpdfTestEvent(new SequenceId(), CommonsProductData.GetInstance(), null, "test event"
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.DoesNotThrow(() => testProcessor.OnEvent(new ConfirmEvent(e)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
[LogMessage("{0} you are probably {1}", LogLevel = LogLevelConstants.INFO, Count = 4)]
|
||||||
|
public virtual void MessageIsLoggedThreeTimesTest() {
|
||||||
|
int iterationsNumber = 15;
|
||||||
|
// "1" correspond to expected iterations with log messages:
|
||||||
|
// 1 0 0 0 0
|
||||||
|
// 0 1 0 0 0
|
||||||
|
// 1 0 0 0 1
|
||||||
|
DefaultTSpdfProductEventProcessorTest.TestDefaultTSpdfProductEventProcessor testProcessor = new DefaultTSpdfProductEventProcessorTest.TestDefaultTSpdfProductEventProcessor
|
||||||
|
();
|
||||||
|
TSpdfTestEvent e = new TSpdfTestEvent(new SequenceId(), CommonsProductData.GetInstance(), null, "test event"
|
||||||
|
);
|
||||||
|
for (int i = 0; i < iterationsNumber; ++i) {
|
||||||
|
NUnit.Framework.Assert.DoesNotThrow(() => testProcessor.OnEvent(new ConfirmEvent(e)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestDefaultTSpdfProductEventProcessor : DefaultTSpdfProductEventProcessor {
|
||||||
|
public TestDefaultTSpdfProductEventProcessor()
|
||||||
|
: base("test product") {
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override long AcquireRepeatLevel(int lvl) {
|
||||||
|
switch (lvl) {
|
||||||
|
case 0: {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1: {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2: {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Commons.Actions;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Processors {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class UnderAgplProductProcessorFactoryTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CreateUnderAgplProductProcessor() {
|
||||||
|
UnderAgplProductProcessorFactory underAgplProductProcessorFactory = new UnderAgplProductProcessorFactory();
|
||||||
|
TSpdfProductEventProcessor processor = underAgplProductProcessorFactory.CreateProcessor(ProductNameConstant
|
||||||
|
.TSpdf_CORE);
|
||||||
|
NUnit.Framework.Assert.IsNotNull(processor);
|
||||||
|
NUnit.Framework.Assert.IsTrue(processor is UnderAgplTSpdfProductEventProcessor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Commons.Actions;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Processors {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class UnderAgplTSpdfProductEventProcessorTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MessageIsNotLoggedTest() {
|
||||||
|
UnderAgplTSpdfProductEventProcessor testProcessor = new UnderAgplTSpdfProductEventProcessor(ProductNameConstant
|
||||||
|
.TSpdf_CORE);
|
||||||
|
TSpdfTestEvent e = new TSpdfTestEvent(new SequenceId(), CommonsProductData.GetInstance(), null, "test event"
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.DoesNotThrow(() => testProcessor.OnEvent(new ConfirmEvent(e)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Producer {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class CopyrightSincePlaceholderPopulatorTest : ExtendedTSpdfTest {
|
||||||
|
private CopyrightSincePlaceholderPopulator populator = new CopyrightSincePlaceholderPopulator();
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void OneEventTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents(1994);
|
||||||
|
String result = populator.Populate(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("1994", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SeveralEventsTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents(2012, 1994, 1998);
|
||||||
|
String result = populator.Populate(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("1994", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SeveralEventsWithSameYearTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents(1992, 1998, 1992, 1998);
|
||||||
|
String result = populator.Populate(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("1992", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IList<ConfirmedEventWrapper> GetEvents(params int[] years) {
|
||||||
|
IList<ConfirmedEventWrapper> events = new List<ConfirmedEventWrapper>();
|
||||||
|
foreach (int year in years) {
|
||||||
|
ProductData productData = new ProductData("TSpdf Test", "TSpdf-test", "25.3", year, 2021);
|
||||||
|
events.Add(new ConfirmedEventWrapper(new TSpdfTestEvent(new SequenceId(), productData, null, "testing"), "AGPL"
|
||||||
|
, "TSpdf test product line"));
|
||||||
|
}
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Producer {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class CopyrightToPlaceholderPopulatorTest : ExtendedTSpdfTest {
|
||||||
|
private CopyrightToPlaceholderPopulator populator = new CopyrightToPlaceholderPopulator();
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void OneEventTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents(2010);
|
||||||
|
String result = populator.Populate(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("2010", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SeveralEventsTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents(2007, 2030, 2020);
|
||||||
|
String result = populator.Populate(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("2030", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SeveralEventsWithSameYearTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents(2009, 1998, 2009, 1998);
|
||||||
|
String result = populator.Populate(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("2009", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IList<ConfirmedEventWrapper> GetEvents(params int[] years) {
|
||||||
|
IList<ConfirmedEventWrapper> events = new List<ConfirmedEventWrapper>();
|
||||||
|
foreach (int year in years) {
|
||||||
|
ProductData productData = new ProductData("TSpdf Test", "TSpdf-test", "25.3", 1900, year);
|
||||||
|
events.Add(new ConfirmedEventWrapper(new TSpdfTestEvent(new SequenceId(), productData, null, "testing"), "AGPL"
|
||||||
|
, "TSpdf test product line"));
|
||||||
|
}
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Exceptions;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Producer {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class CurrentDatePlaceholderPopulatorTest : ExtendedTSpdfTest {
|
||||||
|
private readonly CurrentDatePlaceholderPopulator populator = new CurrentDatePlaceholderPopulator();
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(null
|
||||||
|
, null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED
|
||||||
|
, "currentDate"), exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextTest() {
|
||||||
|
String result = populator.Populate(null, "'plain text'");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain text", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextWithIgnoredBackSlashesTest() {
|
||||||
|
String result = populator.Populate(null, "'\\p\\l\\a\\i\\n \\t\\e\\x\\t'");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain text", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextWithEscapedBackSlashesTest() {
|
||||||
|
String result = populator.Populate(null, "'plain\\\\text'");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain\\text", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextWithEscapedApostrophesTest() {
|
||||||
|
String result = populator.Populate(null, "'plain\\'text'");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain'text", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextSeveralQuotedStringsTest() {
|
||||||
|
String result = populator.Populate(null, "'plain'' ''text'");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain text", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextWithUnquotedCharactersTest() {
|
||||||
|
String result = populator.Populate(null, "'plain text'$$$");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain text$$$", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextEndlessQuotationErrorTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(null
|
||||||
|
, "'plain text"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, exception
|
||||||
|
.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextMultipleQuotationsEndlessQuotationErrorTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(null
|
||||||
|
, "'plain'' ''text"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, exception
|
||||||
|
.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextEscapedApostropheEndlessQuotationErrorTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(null
|
||||||
|
, "'plain text\\'"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, exception
|
||||||
|
.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ValidComponentsTest() {
|
||||||
|
NUnit.Framework.Assert.DoesNotThrow(() => populator.Populate(null, "dd MM MMM MMMM yy yyyy HH mm ss"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ValidComponentsComparisonTest() {
|
||||||
|
// the test may potentially fail if you started it at HH:59:59 so that expected result will
|
||||||
|
// be generated at the beginning of the next hour.
|
||||||
|
DateTime date = DateTimeUtil.GetCurrentUtcTime();
|
||||||
|
String result = populator.Populate(null, "dd MM yy yyyy HH");
|
||||||
|
String expectedResult = DateTimeUtil.Format(date, "dd MM yy yyyy HH");
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UnexpectedLetterComponentTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(null
|
||||||
|
, "dd MM tyy yyyy HH"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT
|
||||||
|
, "t"), exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UnexpectedLongComponentTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(null
|
||||||
|
, "dd MMMMM yy yyyy HH"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT
|
||||||
|
, "MMMMM"), exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UnexpectedShortComponentTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(null
|
||||||
|
, "dd MM y yyyy HH"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT
|
||||||
|
, "y"), exception.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Commons.Exceptions;
|
||||||
|
using TSpdf.Commons.Logs;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using TSpdf.Test.Attributes;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Producer {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class ProducerBuilderTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void EmptyEventsProducerLineTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => ProducerBuilder.ModifyProducer
|
||||||
|
(JavaCollectionsUtil.EmptyList<AbstractProductProcessTSpdfEvent>(), null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullEventsProducerLineTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => ProducerBuilder.ModifyProducer
|
||||||
|
((IList<AbstractProductProcessTSpdfEvent>)null, null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextNewProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Plain Text", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("Plain Text", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextEmptyOldProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Plain Text", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, "");
|
||||||
|
NUnit.Framework.Assert.AreEqual("Plain Text", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextExistingOldProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Plain Text", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, "Old producer");
|
||||||
|
NUnit.Framework.Assert.AreEqual("Old producer; modified using Plain Text", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextExistingOldProducerWithModifiedPartLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("New Author", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, "Old producer; modified using Plain Text");
|
||||||
|
NUnit.Framework.Assert.AreEqual("Old producer; modified using Plain Text; modified using New Author", newProducerLine
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CopyrightSinceProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Prod. since ${copyrightSince}", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("Prod. since 1901", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CopyrightToProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("All rights reserved, ${copyrightTo}", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("All rights reserved, 2103", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CurrentDateProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Created at ${currentDate:yyyy}", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("Created at " + DateTimeUtil.Format(DateTimeUtil.GetCurrentUtcTime(), "yyyy"
|
||||||
|
), newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CurrentDateComplexFormatProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Created at ${currentDate:yyyy, '{\\'yes::yes\\'', yyyy}",
|
||||||
|
1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
String currentYear = DateTimeUtil.Format(DateTimeUtil.GetCurrentUtcTime(), "yyyy");
|
||||||
|
NUnit.Framework.Assert.AreEqual("Created at " + currentYear + ", {'yes::yes', " + currentYear, newProducerLine
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CurrentDatePlaceholderFormatProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Created at ${currentDate:'${currentDate'}", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("Created at ${currentDate", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CurrentDateNoFormatProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Created at ${currentDate}", 1, 2, 3);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => ProducerBuilder.ModifyProducer
|
||||||
|
(events, null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED
|
||||||
|
, "currentDate"), exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void CurrentDateEmptyFormatProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Created at ${currentDate:}", 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("Created at ", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UsedProductsProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Used products: ${usedProducts:P #V (T 'version')}", 1, 2,
|
||||||
|
3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("Used products: product1 #1.0 (type1 version), product2 #2.0 (type2 version), product3 #3.0 (type3 version)"
|
||||||
|
, newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UsedProductsEmptyFormatProducerLineTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("Used products: ${usedProducts}", 1, 2, 3);
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => ProducerBuilder.ModifyProducer
|
||||||
|
(events, null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED
|
||||||
|
, "usedProducts"), exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
[LogMessage(CommonsLogMessageConstant.UNKNOWN_PLACEHOLDER_WAS_IGNORED, Count = 3, LogLevel = LogLevelConstants
|
||||||
|
.INFO)]
|
||||||
|
public virtual void UnknownPlaceHoldersTest() {
|
||||||
|
IList<ConfirmedEventWrapper> events = GetEvents("${plchldr}|${plchldrWithParam:param}|${plchldrWithWeirdParam::$$:'''\\''}"
|
||||||
|
, 1, 2, 3);
|
||||||
|
String newProducerLine = ProducerBuilder.ModifyProducer(events, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual("||", newProducerLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IList<ConfirmedEventWrapper> GetEvents(String initialProducerLine, params int[] indexes) {
|
||||||
|
IList<ConfirmedEventWrapper> events = new List<ConfirmedEventWrapper>();
|
||||||
|
for (int ind = 0; ind < indexes.Length; ind++) {
|
||||||
|
int i = indexes[ind];
|
||||||
|
ProductData productData = new ProductData("product" + i, "module" + i, i + ".0", 1900 + i, 2100 + i);
|
||||||
|
events.Add(new ConfirmedEventWrapper(new TSpdfTestEvent(new SequenceId(), productData, null, "testing" + i
|
||||||
|
), "type" + i, ind == 0 ? initialProducerLine : "TSpdf product " + i));
|
||||||
|
}
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
using TSpdf.Commons.Ecosystem;
|
||||||
|
using TSpdf.Commons.Exceptions;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Producer {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class UsedProductsPlaceholderPopulatorTest : ExtendedTSpdfTest {
|
||||||
|
private readonly UsedProductsPlaceholderPopulator populator = new UsedProductsPlaceholderPopulator();
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(GetEvents
|
||||||
|
(1), null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED
|
||||||
|
, "usedProducts"), exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextTest() {
|
||||||
|
String result = populator.Populate(GetEvents(0), "'plain text'");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain text", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PlainTextMultipleEventsMergedTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1, 2, 3, 4), "'plain text'");
|
||||||
|
NUnit.Framework.Assert.AreEqual("plain text", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ProductNameOneEventTest() {
|
||||||
|
String result = populator.Populate(GetEvents(0), "P");
|
||||||
|
NUnit.Framework.Assert.AreEqual("product0", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ProductNameSeveralEventsTest() {
|
||||||
|
String result = populator.Populate(GetEvents(0, 1, 2), "P");
|
||||||
|
NUnit.Framework.Assert.AreEqual("product0, product1, product2", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SameProductsMergedTest() {
|
||||||
|
String result = populator.Populate(GetEvents(0, 1, 0, 1, 2), "P");
|
||||||
|
NUnit.Framework.Assert.AreEqual("product0, product1, product2", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void VersionOneEventTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1), "V");
|
||||||
|
NUnit.Framework.Assert.AreEqual("1.0", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void VersionSeveralEventsTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1, 2, 3), "V");
|
||||||
|
NUnit.Framework.Assert.AreEqual("1.0, 2.0, 3.0", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SameVersionsMergedTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1, 2, 1, 2, 3), "V");
|
||||||
|
NUnit.Framework.Assert.AreEqual("1.0, 2.0, 3.0", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TypeOneEventTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1), "T");
|
||||||
|
NUnit.Framework.Assert.AreEqual("type1", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TypeSeveralEventsTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1, 2, 3), "T");
|
||||||
|
NUnit.Framework.Assert.AreEqual("type1, type2, type3", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SameTypesMergedTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1, 2, 1, 2, 3), "T");
|
||||||
|
NUnit.Framework.Assert.AreEqual("type1, type2, type3", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ComplexFormatTest() {
|
||||||
|
String result = populator.Populate(GetEvents(1, 2, 1, 2, 3), "'module:'P #V (T)");
|
||||||
|
NUnit.Framework.Assert.AreEqual("module:product1 #1.0 (type1), module:product2 #2.0 (type2), module:product3 #3.0 (type3)"
|
||||||
|
, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void HumanReadableNormalizationTest() {
|
||||||
|
ProductData productData = new ProductData("public-name", "name", "1.0.0", 2020, 2021);
|
||||||
|
ConfirmedEventWrapper @event = new ConfirmedEventWrapper(new TSpdfTestEvent(new SequenceId(), productData,
|
||||||
|
null, "testing"), "nonproduction", "TSpdf product");
|
||||||
|
String result = populator.Populate(JavaUtil.ArraysAsList(@event), "'module:'P #V (T)");
|
||||||
|
NUnit.Framework.Assert.AreEqual("module:public-name #1.0.0 (non-production)", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void InvalidLetterFormatTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(ArgumentException), () => populator.Populate(GetEvents
|
||||||
|
(1), "PVTX"));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_CHARACTER
|
||||||
|
, "X"), exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IList<ConfirmedEventWrapper> GetEvents(params int[] indexes) {
|
||||||
|
IList<ConfirmedEventWrapper> events = new List<ConfirmedEventWrapper>();
|
||||||
|
foreach (int i in indexes) {
|
||||||
|
ProductData productData = new ProductData("product" + i, "module" + i, i + ".0", 1900, 2100);
|
||||||
|
events.Add(new ConfirmedEventWrapper(new TSpdfTestEvent(new SequenceId(), productData, null, "testing" + i
|
||||||
|
), "type" + i, "TSpdf product " + i));
|
||||||
|
}
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Exceptions;
|
||||||
|
using TSpdf.Commons.Utils;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Sequence {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class SequenceIdManagerTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SetIdentifier() {
|
||||||
|
SequenceIdManagerTest.IdentifiableElement element = new SequenceIdManagerTest.IdentifiableElement();
|
||||||
|
NUnit.Framework.Assert.IsNull(SequenceIdManager.GetSequenceId(element));
|
||||||
|
SequenceId sequenceId = new SequenceId();
|
||||||
|
SequenceIdManager.SetSequenceId(element, sequenceId);
|
||||||
|
NUnit.Framework.Assert.AreEqual(sequenceId, SequenceIdManager.GetSequenceId(element));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void OverrideIdentifierTest() {
|
||||||
|
SequenceIdManagerTest.IdentifiableElement element = new SequenceIdManagerTest.IdentifiableElement();
|
||||||
|
SequenceId sequenceId1 = new SequenceId();
|
||||||
|
SequenceId sequenceId2 = new SequenceId();
|
||||||
|
SequenceIdManager.SetSequenceId(element, sequenceId1);
|
||||||
|
Exception e = NUnit.Framework.Assert.Catch(typeof(InvalidOperationException), () => SequenceIdManager.SetSequenceId
|
||||||
|
(element, sequenceId2));
|
||||||
|
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(CommonsExceptionMessageConstant.ELEMENT_ALREADY_HAS_IDENTIFIER
|
||||||
|
, sequenceId1.GetId(), sequenceId2.GetId()), e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class IdentifiableElement : AbstractIdentifiableElement {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Actions.Sequence {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class SequenceIdTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DifferentIdsCreatedTest() {
|
||||||
|
SequenceId sequenceId1 = new SequenceId();
|
||||||
|
SequenceId sequenceId2 = new SequenceId();
|
||||||
|
NUnit.Framework.Assert.AreNotEqual(sequenceId1.GetId(), sequenceId2.GetId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Actions;
|
||||||
|
using TSpdf.Commons.Actions.Confirmations;
|
||||||
|
using TSpdf.Commons.Actions.Contexts;
|
||||||
|
using TSpdf.Commons.Actions.Data;
|
||||||
|
using TSpdf.Commons.Actions.Sequence;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Ecosystem {
|
||||||
|
public class TSpdfTestEvent : AbstractProductProcessTSpdfEvent {
|
||||||
|
private readonly String eventType;
|
||||||
|
|
||||||
|
public TSpdfTestEvent(SequenceId sequenceId, IMetaInfo metaInfo, String eventType, String productName)
|
||||||
|
: base(sequenceId, new ProductData("", productName, "", 2000, 2100), metaInfo, EventConfirmationType.ON_CLOSE
|
||||||
|
) {
|
||||||
|
this.eventType = eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TSpdfTestEvent(SequenceId sequenceId, ProductData productData, IMetaInfo metaInfo, String eventType
|
||||||
|
, EventConfirmationType confirmationType)
|
||||||
|
: base(sequenceId, productData, metaInfo, confirmationType) {
|
||||||
|
this.eventType = eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TSpdfTestEvent(SequenceId sequenceId, ProductData productData, IMetaInfo metaInfo, String eventType
|
||||||
|
)
|
||||||
|
: this(sequenceId, productData, metaInfo, eventType, EventConfirmationType.ON_CLOSE) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public override String GetEventType() {
|
||||||
|
return eventType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using TSpdf.Commons;
|
||||||
|
using TSpdf.Commons.Actions;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Ecosystem {
|
||||||
|
public class TestConfigurationEvent : AbstractTSpdfConfigurationEvent {
|
||||||
|
public const String MESSAGE = "Test configuration event was processed";
|
||||||
|
|
||||||
|
private static readonly ILogger LOGGER = TSpdfLogManager.GetLogger(typeof(TestConfigurationEvent));
|
||||||
|
|
||||||
|
protected internal override void DoAction() {
|
||||||
|
LOGGER.LogWarning(MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Commons.Actions.Contexts;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Ecosystem {
|
||||||
|
public class TestMetaInfo : IMetaInfo {
|
||||||
|
private readonly String metaData;
|
||||||
|
|
||||||
|
public TestMetaInfo(String metaData) {
|
||||||
|
this.metaData = metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual String GetMetaData() {
|
||||||
|
return metaData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Exceptions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class AggregatedExceptionTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void AggregatedMessageWithGeneralMessageTest() {
|
||||||
|
IList<Exception> exceptions = new List<Exception>();
|
||||||
|
exceptions.Add(new Exception("Message 1"));
|
||||||
|
exceptions.Add(new Exception("Message 2"));
|
||||||
|
exceptions.Add(new AggregatedExceptionTest.CustomException("Message 3"));
|
||||||
|
AggregatedException exception = new AggregatedException("General message", exceptions);
|
||||||
|
NUnit.Framework.Assert.AreEqual(exceptions, exception.GetAggregatedExceptions());
|
||||||
|
NUnit.Framework.Assert.AreEqual("General message:\n" + "0) Message 1\n" + "1) Message 2\n" + "2) Message 3\n"
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void AggregatedMessageWithoutGeneralMessageTest() {
|
||||||
|
IList<Exception> exceptions = new List<Exception>();
|
||||||
|
exceptions.Add(new Exception("Message 1"));
|
||||||
|
exceptions.Add(new Exception("Message 2"));
|
||||||
|
exceptions.Add(new AggregatedExceptionTest.CustomException("Message 3"));
|
||||||
|
AggregatedException exception = new AggregatedException(exceptions);
|
||||||
|
NUnit.Framework.Assert.AreEqual("Aggregated message:\n" + "0) Message 1\n" + "1) Message 2\n" + "2) Message 3\n"
|
||||||
|
, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class CustomException : Exception {
|
||||||
|
public CustomException(String message)
|
||||||
|
: base(message) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Exceptions {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class TSpdfExceptionTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NoParametersConstructorTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(TSpdfException), () => {
|
||||||
|
throw new TSpdfException();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.UNKNOWN_TSpdf_EXCEPTION, exception.Message
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void StringConstructorTest() {
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(TSpdfException), () => {
|
||||||
|
throw new TSpdfException("message");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.AreEqual("message", exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void ThrowableConstructorTest() {
|
||||||
|
Exception cause = new Exception("cause");
|
||||||
|
Exception exception = NUnit.Framework.Assert.Catch(typeof(TSpdfException), () => {
|
||||||
|
throw new TSpdfException(cause);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CommonsExceptionMessageConstant.UNKNOWN_TSpdf_EXCEPTION, exception.Message
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.AreEqual(cause, exception.InnerException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils.Collections {
|
||||||
|
public class EmptySetTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void RemoveValueFromEmptySetTest() {
|
||||||
|
EmptySet<string> emptySet = new EmptySet<string>();
|
||||||
|
NUnit.Framework.Assert.False(emptySet.Remove("any value"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
public class DateTimeUtilTest : ExtendedTSpdfTest {
|
||||||
|
|
||||||
|
private const double ZERO_DELTA = 1e-6;
|
||||||
|
private const double ONE_SECOND_DELTA = 1000.0;
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void GetCurrentTest() {
|
||||||
|
DateTime date = DateTime.Now;
|
||||||
|
Assert.AreEqual(date.ToString(), DateTimeUtil.GetCurrentTime().ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void IsInPastTest() {
|
||||||
|
DateTime date = new DateTime(1);
|
||||||
|
Assert.IsTrue(DateTimeUtil.IsInPast(date));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ParseDateAndGetUtcMillisFromEpochTest()
|
||||||
|
{
|
||||||
|
DateTime date = DateTimeUtil.ParseWithDefaultPattern("2020-05-05");
|
||||||
|
DateTime parsedDate = DateTimeUtil.GetCalendar(date);
|
||||||
|
double millisFromEpochTo2020_05_05 = DateTimeUtil.GetUtcMillisFromEpoch(parsedDate);
|
||||||
|
|
||||||
|
long offset = DateTimeUtil.GetCurrentTimeZoneOffset(date);
|
||||||
|
Assert.AreEqual(1588636800000d - offset, millisFromEpochTo2020_05_05, ZERO_DELTA);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CompareUtcMillisFromEpochWithNullParamAndCurrentTimeTest() {
|
||||||
|
double getUtcMillisFromEpochWithNullParam = DateTimeUtil.GetUtcMillisFromEpoch(null);
|
||||||
|
double millisFromEpochToCurrentTime = DateTimeUtil.GetUtcMillisFromEpoch(DateTimeUtil.GetCurrentUtcTime());
|
||||||
|
|
||||||
|
Assert.AreEqual(millisFromEpochToCurrentTime, getUtcMillisFromEpochWithNullParam, ONE_SECOND_DELTA);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ParseDateAndGetRelativeTimeTest()
|
||||||
|
{
|
||||||
|
DateTime date = DateTimeUtil.ParseWithDefaultPattern("2020-05-05");
|
||||||
|
long relativeTime = DateTimeUtil.GetRelativeTime(date);
|
||||||
|
|
||||||
|
long offset = DateTimeUtil.GetCurrentTimeZoneOffset(date);
|
||||||
|
|
||||||
|
Assert.AreEqual(1588636800000d - offset, relativeTime, ZERO_DELTA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,232 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils
|
||||||
|
{
|
||||||
|
public class FormattingStreamWriterUnitTest : ExtendedTSpdfTest {
|
||||||
|
|
||||||
|
[NUnit.Framework.OneTimeSetUp]
|
||||||
|
public static void BeforeClass() {
|
||||||
|
CultureInfo culture = (CultureInfo) new System.Globalization.CultureInfo("ru-RU");
|
||||||
|
culture.NumberFormat.NegativeSign = "--";
|
||||||
|
Thread.CurrentThread.CurrentCulture = culture;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void BooleanTest() {
|
||||||
|
Boolean value = true;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
string result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("True", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PositiveDoubleTest() {
|
||||||
|
Double value = 123.579;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
string result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("123.579", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NegativeDoubleTest() {
|
||||||
|
Double value = -123.579;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
string result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("-123.579", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PositiveSingleTest() {
|
||||||
|
Single value = 123.5f;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
string result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("123.5", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NegativeSingleTest() {
|
||||||
|
Single value = -123.5f;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("-123.5", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PositiveDecimalTest() {
|
||||||
|
decimal value = 2478;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("2478", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NegativeDecimalTest() {
|
||||||
|
decimal value = -2478;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("-2478", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PositiveInt32Test() {
|
||||||
|
Int32 value = 2478;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("2478", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NegativeInt32Test() {
|
||||||
|
Int32 value = -2478;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("-2478", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PositiveInt64Test() {
|
||||||
|
Int64 value = 2478;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("2478", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NegativeInt64Test() {
|
||||||
|
Int64 value = -2478;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("-2478", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void UInt32Test() {
|
||||||
|
UInt32 value = 2478;
|
||||||
|
|
||||||
|
Stream stream = new MemoryStream();
|
||||||
|
FormattingStreamWriter writer = new FormattingStreamWriter(stream);
|
||||||
|
writer.Write(value);
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(stream);
|
||||||
|
String result = reader.ReadToEnd();
|
||||||
|
NUnit.Framework.Assert.AreEqual("2478", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
public class JavaUtilTest {
|
||||||
|
[Test]
|
||||||
|
public virtual void LinkedHashSetTest() {
|
||||||
|
LinkedHashSet<int> set1 = new LinkedHashSet<int>();
|
||||||
|
set1.Add(5);
|
||||||
|
set1.Add(2);
|
||||||
|
set1.Add(3);
|
||||||
|
set1.Add(5);
|
||||||
|
|
||||||
|
Assert.AreEqual(5, set1.First());
|
||||||
|
Assert.AreEqual(3, set1.Last());
|
||||||
|
Assert.AreEqual(3, set1.Count);
|
||||||
|
|
||||||
|
LinkedHashSet<int> set2 = new LinkedHashSet<int>();
|
||||||
|
set2.Add(2);
|
||||||
|
set2.Add(5);
|
||||||
|
|
||||||
|
Assert.True(set1.IsSupersetOf(set2));
|
||||||
|
Assert.True(set1.IsProperSupersetOf(set2));
|
||||||
|
Assert.True(set2.IsSubsetOf(set1));
|
||||||
|
Assert.True(set2.IsProperSubsetOf(set1));
|
||||||
|
|
||||||
|
Assert.False(set2.IsSupersetOf(set1));
|
||||||
|
|
||||||
|
LinkedHashSet<int> set3 = new LinkedHashSet<int>();
|
||||||
|
set3.Add(5);
|
||||||
|
set3.Add(2);
|
||||||
|
|
||||||
|
Assert.True(set3.SetEquals(set2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaCollectionsUtilTest() {
|
||||||
|
IList<int> emptyList = JavaCollectionsUtil.EmptyList<int>();
|
||||||
|
Assert.IsEmpty(emptyList);
|
||||||
|
Assert.Throws<NotSupportedException>(() => emptyList.Add(10));
|
||||||
|
|
||||||
|
IDictionary<int, int> emptyMap = JavaCollectionsUtil.EmptyMap<int, int>();
|
||||||
|
Assert.IsEmpty(emptyMap);
|
||||||
|
Assert.Throws<NotSupportedException>(() => { emptyMap[5] = 10; });
|
||||||
|
|
||||||
|
IEnumerator<int> emptyIterator = JavaCollectionsUtil.EmptyIterator<int>();
|
||||||
|
Assert.False(emptyIterator.MoveNext());
|
||||||
|
|
||||||
|
IList<int> unmodifiableList =
|
||||||
|
JavaCollectionsUtil.UnmodifiableList<int>(new int[] {10, 20, 30, 20}.ToList());
|
||||||
|
Assert.Throws<NotSupportedException>(() => unmodifiableList.Insert(0, 20));
|
||||||
|
Assert.Throws<NotSupportedException>(() => { unmodifiableList[2] = 50; });
|
||||||
|
int test = unmodifiableList[3];
|
||||||
|
Assert.Throws<NotSupportedException>(() => JavaCollectionsUtil.Sort(unmodifiableList));
|
||||||
|
|
||||||
|
IDictionary<int, int> unodifiableMap = JavaCollectionsUtil.UnmodifiableMap(new Dictionary<int, int>() {
|
||||||
|
{1, 20},
|
||||||
|
{2, 40},
|
||||||
|
{70, 80},
|
||||||
|
});
|
||||||
|
test = unodifiableMap[2];
|
||||||
|
Assert.Throws<KeyNotFoundException>(() => {
|
||||||
|
int temp = unodifiableMap[3];
|
||||||
|
});
|
||||||
|
Assert.Throws<NotSupportedException>(() => { unodifiableMap[11] = 11; });
|
||||||
|
|
||||||
|
IList<int> singletonList = JavaCollectionsUtil.SingletonList(4);
|
||||||
|
Assert.AreEqual(4, singletonList[0]);
|
||||||
|
Assert.Throws<NotSupportedException>(() => singletonList.Add(9));
|
||||||
|
|
||||||
|
List<int> x = new int[] {60, 50, 20}.ToList();
|
||||||
|
JavaCollectionsUtil.Sort(x);
|
||||||
|
Assert.AreEqual(20, x[0]);
|
||||||
|
Assert.AreEqual(60, x[2]);
|
||||||
|
|
||||||
|
x = new int[] {-1, 0, 1}.ToList();
|
||||||
|
JavaCollectionsUtil.Reverse(x);
|
||||||
|
Assert.AreEqual(1, x[0]);
|
||||||
|
Assert.AreEqual(0, x[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillBytesTest() {
|
||||||
|
byte[] bytes = new byte[5];
|
||||||
|
byte fillVal = 1;
|
||||||
|
JavaUtil.Fill(bytes, fillVal);
|
||||||
|
foreach (byte b in bytes) {
|
||||||
|
Assert.AreEqual(fillVal, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillCharsTest() {
|
||||||
|
char[] chars = new char[5];
|
||||||
|
char fillVal = 'a';
|
||||||
|
JavaUtil.Fill(chars, fillVal);
|
||||||
|
foreach (char c in chars) {
|
||||||
|
Assert.AreEqual(fillVal, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillBoolTest() {
|
||||||
|
bool[] bools = new bool[5];
|
||||||
|
bool fillVal = true;
|
||||||
|
JavaUtil.Fill(bools, fillVal);
|
||||||
|
foreach (bool b in bools) {
|
||||||
|
Assert.AreEqual(fillVal, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillShortTest() {
|
||||||
|
short[] shorts = new short[5];
|
||||||
|
short fillVal = 1;
|
||||||
|
JavaUtil.Fill(shorts, fillVal);
|
||||||
|
foreach (short b in shorts) {
|
||||||
|
Assert.AreEqual(fillVal, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillIntTest() {
|
||||||
|
int[] ints = new int[5];
|
||||||
|
int fillVal = 1;
|
||||||
|
JavaUtil.Fill(ints, fillVal);
|
||||||
|
foreach (int b in ints) {
|
||||||
|
Assert.AreEqual(fillVal, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillLongTest() {
|
||||||
|
long[] longs = new long[5];
|
||||||
|
long fillVal = 1;
|
||||||
|
JavaUtil.Fill(longs, fillVal);
|
||||||
|
foreach (long b in longs) {
|
||||||
|
Assert.AreEqual(fillVal, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillFloatTest() {
|
||||||
|
float[] floats = new float[5];
|
||||||
|
float fillVal = 1;
|
||||||
|
JavaUtil.Fill(floats, fillVal);
|
||||||
|
foreach (float b in floats) {
|
||||||
|
Assert.AreEqual(fillVal, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillDoubleTest() {
|
||||||
|
double[] doubles = new double[5];
|
||||||
|
double fillVal = 1;
|
||||||
|
JavaUtil.Fill(doubles, fillVal);
|
||||||
|
foreach (double d in doubles) {
|
||||||
|
Assert.AreEqual(fillVal, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public virtual void JavaUtilFillObjectTest() {
|
||||||
|
string[] strings = new string[5];
|
||||||
|
string fillVal = "hello";
|
||||||
|
JavaUtil.Fill(strings, fillVal);
|
||||||
|
foreach (string s in strings) {
|
||||||
|
Assert.AreEqual(fillVal, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,576 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using TSpdf.Commons.Logs;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using TSpdf.Test.Attributes;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class JsonUtilTest : ExtendedTSpdfTest {
|
||||||
|
private static readonly String SOURCE_FOLDER = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/commons/utils/JsonUtilTest/";
|
||||||
|
|
||||||
|
private static bool isRunOnJava = false;
|
||||||
|
|
||||||
|
static JsonUtilTest() {
|
||||||
|
// Android-Conversion-Skip-Block-Start (cutting area is used to understand whether code is running on Android or not)
|
||||||
|
isRunOnJava = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Android-Conversion-Skip-Block-End
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Utf8CharsetStringTest() {
|
||||||
|
NUnit.Framework.Assert.AreEqual("\"©\"", JsonUtil.SerializeToString("©"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void Utf8CharsetStreamTest() {
|
||||||
|
MemoryStream byteArray = new MemoryStream();
|
||||||
|
JsonUtil.SerializeToStream(byteArray, "©");
|
||||||
|
NUnit.Framework.Assert.AreEqual("\"©\"", EncodingUtil.ConvertToString(byteArray.ToArray(), "UTF-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeInstanceWithEnumStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "classWithEnum.json";
|
||||||
|
JsonUtilTest.ClassWithEnum classWithEnum = CreateClassWithEnumObject();
|
||||||
|
String resultString = JsonUtil.SerializeToString(classWithEnum);
|
||||||
|
String cmpString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(cmpString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeInstanceWithEnumStreamTest() {
|
||||||
|
// Android-Conversion-Ignore-Test (TODO DEVSIX-7371 investigate different behavior of a few TSpdfCore tests on Java and Android)
|
||||||
|
String cmp;
|
||||||
|
if (isRunOnJava) {
|
||||||
|
cmp = SOURCE_FOLDER + "classWithEnum.json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Test is run on Android, so field order will be different from Java.
|
||||||
|
cmp = SOURCE_FOLDER + "classWithEnumAndroid.json";
|
||||||
|
}
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(cmp)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToStream(serializationResult, CreateClassWithEnumObject());
|
||||||
|
serializationResult.Flush();
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalInstanceWithEnumStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "minimalClassWithEnum.json";
|
||||||
|
JsonUtilTest.ClassWithEnum classWithEnum = CreateClassWithEnumObject();
|
||||||
|
String resultString = JsonUtil.SerializeToMinimalString(classWithEnum);
|
||||||
|
String compareString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(compareString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalInstanceWithEnumStreamTest() {
|
||||||
|
// Android-Conversion-Ignore-Test (TODO DEVSIX-7371 investigate different behavior of a few TSpdfCore tests on Java and Android)
|
||||||
|
String cmp;
|
||||||
|
if (isRunOnJava) {
|
||||||
|
cmp = SOURCE_FOLDER + "minimalClassWithEnum.json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Test is run on Android, so field order will be different from Java.
|
||||||
|
cmp = SOURCE_FOLDER + "minimalClassWithEnumAndroid.json";
|
||||||
|
}
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(cmp)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToMinimalStream(serializationResult, CreateClassWithEnumObject());
|
||||||
|
serializationResult.Flush();
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeStringWithLineBreakStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "stringsWithLineBreaks.json";
|
||||||
|
String[] stringsForSerialization = CreateStringWithLineBreaks();
|
||||||
|
String resultString = JsonUtil.SerializeToString(stringsForSerialization);
|
||||||
|
String cmpString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.AreEqual(cmpString, resultString);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeStringWithLineBreakStreamTest() {
|
||||||
|
String path = SOURCE_FOLDER + "stringsWithLineBreaks.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(path)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToStream(serializationResult, CreateStringWithLineBreaks());
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalStringWithLineBreakStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "minimalStringsWithLineBreaks.json";
|
||||||
|
String[] stringsForSerialization = CreateStringWithLineBreaks();
|
||||||
|
String resultString = JsonUtil.SerializeToMinimalString(stringsForSerialization);
|
||||||
|
String cmpString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.AreEqual(cmpString, resultString);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalStringWithLineBreakStreamTest() {
|
||||||
|
String path = SOURCE_FOLDER + "minimalStringsWithLineBreaks.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(path)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToMinimalStream(serializationResult, CreateStringWithLineBreaks());
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeComplexStructureStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "complexStructure.json";
|
||||||
|
JsonUtilTest.ComplexStructure complexStructure = CreateComplexStructureObject();
|
||||||
|
String resultString = JsonUtil.SerializeToString(complexStructure);
|
||||||
|
String compareString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(compareString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeComplexStructureStreamTest() {
|
||||||
|
// Android-Conversion-Ignore-Test (TODO DEVSIX-7371 investigate different behavior of a few TSpdfCore tests on Java and Android)
|
||||||
|
String cmp;
|
||||||
|
if (isRunOnJava) {
|
||||||
|
cmp = SOURCE_FOLDER + "complexStructure.json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Test is run on Android, so field order will be different from Java.
|
||||||
|
cmp = SOURCE_FOLDER + "complexStructureAndroid.json";
|
||||||
|
}
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(cmp)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToStream(serializationResult, CreateComplexStructureObject());
|
||||||
|
NUnit.Framework.Assert.AreNotEqual(0, serializationResult.Length);
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalComplexStructureStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "minimalComplexStructure.json";
|
||||||
|
JsonUtilTest.ComplexStructure complexStructure = CreateComplexStructureObject();
|
||||||
|
String resultString = JsonUtil.SerializeToMinimalString(complexStructure);
|
||||||
|
String compareString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(compareString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalComplexStructureStreamTest() {
|
||||||
|
// Android-Conversion-Ignore-Test (TODO DEVSIX-7371 investigate different behavior of a few TSpdfCore tests on Java and Android)
|
||||||
|
String cmp;
|
||||||
|
if (isRunOnJava) {
|
||||||
|
cmp = SOURCE_FOLDER + "minimalComplexStructure.json";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Test is run on Android, so field order will be different from Java.
|
||||||
|
cmp = SOURCE_FOLDER + "minimalComplexStructureAndroid.json";
|
||||||
|
}
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(cmp)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToMinimalStream(serializationResult, CreateComplexStructureObject());
|
||||||
|
NUnit.Framework.Assert.AreNotEqual(0, serializationResult.Length);
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeWithNullFieldsStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "serializeWithNullFields.json";
|
||||||
|
JsonUtilTest.ClassWithDefaultValue complexStructure = CreateClassWithDefaultValueObject(null, 4, null);
|
||||||
|
String resultString = JsonUtil.SerializeToString(complexStructure);
|
||||||
|
String compareString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(compareString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeWithNullFieldsStreamTest() {
|
||||||
|
String path = SOURCE_FOLDER + "serializeWithNullFields.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(path)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToStream(serializationResult, CreateClassWithDefaultValueObject(null, 4, null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalWithNullFieldsStringTest() {
|
||||||
|
String cmp = SOURCE_FOLDER + "minimalSerializeWithNullFields.json";
|
||||||
|
JsonUtilTest.ClassWithDefaultValue complexStructure = CreateClassWithDefaultValueObject(null, 4, null);
|
||||||
|
String resultString = JsonUtil.SerializeToMinimalString(complexStructure);
|
||||||
|
String compareString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(compareString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SerializeToMinimalWithNullFieldsStreamTest() {
|
||||||
|
String path = SOURCE_FOLDER + "minimalSerializeWithNullFields.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(path)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToMinimalStream(serializationResult, CreateClassWithDefaultValueObject(null, 4, null));
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
[LogMessage(CommonsLogMessageConstant.UNABLE_TO_DESERIALIZE_JSON, LogLevel = LogLevelConstants.WARN)]
|
||||||
|
public virtual void DeserializeInvalidJsonFileStringTest() {
|
||||||
|
String source = SOURCE_FOLDER + "invalidJson.json";
|
||||||
|
String jsonString = GetJsonStringFromFile(source);
|
||||||
|
String resultStr = JsonUtil.DeserializeFromString<String>(jsonString);
|
||||||
|
NUnit.Framework.Assert.IsNull(resultStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
[LogMessage(CommonsLogMessageConstant.UNABLE_TO_DESERIALIZE_JSON, LogLevel = LogLevelConstants.WARN)]
|
||||||
|
public virtual void DeserializeInvalidJsonFileStreamTest() {
|
||||||
|
String source = SOURCE_FOLDER + "invalidJson.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(source)) {
|
||||||
|
String resultStr = JsonUtil.DeserializeFromStream<String>(inputStream);
|
||||||
|
NUnit.Framework.Assert.IsNull(resultStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeWithDefaultValueStringTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithDefaultValue.json";
|
||||||
|
String jsonString = GetJsonStringFromFile(source);
|
||||||
|
JsonUtilTest.ClassWithDefaultValue instance = JsonUtil.DeserializeFromString<JsonUtilTest.ClassWithDefaultValue
|
||||||
|
>(jsonString);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithDefaultValueObject(null, 2, 5.0), instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeWithDefaultValueStreamTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithDefaultValue.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(source)) {
|
||||||
|
JsonUtilTest.ClassWithDefaultValue instance = JsonUtil.DeserializeFromStream<JsonUtilTest.ClassWithDefaultValue
|
||||||
|
>(inputStream);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithDefaultValueObject(null, 2, 5.0), instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeComplexStructureStringTest() {
|
||||||
|
String source = SOURCE_FOLDER + "complexStructure.json";
|
||||||
|
String jsonString = GetJsonStringFromFile(source);
|
||||||
|
JsonUtilTest.ComplexStructure complexStructure = JsonUtil.DeserializeFromString<JsonUtilTest.ComplexStructure
|
||||||
|
>(jsonString);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateComplexStructureObject(), complexStructure);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeComplexStructureStreamTest() {
|
||||||
|
String source = SOURCE_FOLDER + "complexStructure.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(source)) {
|
||||||
|
JsonUtilTest.ComplexStructure complexStructure = JsonUtil.DeserializeFromStream<JsonUtilTest.ComplexStructure
|
||||||
|
>(inputStream);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateComplexStructureObject(), complexStructure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeInstanceWithEnumStringTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithEnum.json";
|
||||||
|
String jsonString = GetJsonStringFromFile(source);
|
||||||
|
JsonUtilTest.ClassWithEnum classWithEnum = JsonUtil.DeserializeFromString<JsonUtilTest.ClassWithEnum>(jsonString
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithEnumObject(), classWithEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeInstanceWithEnumStreamTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithEnum.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(source)) {
|
||||||
|
JsonUtilTest.ClassWithEnum classWithEnum = JsonUtil.DeserializeFromStream<JsonUtilTest.ClassWithEnum>(inputStream
|
||||||
|
);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithEnumObject(), classWithEnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeWithUnknownPropertiesStringTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithUnknownProperties.json";
|
||||||
|
String jsonString = GetJsonStringFromFile(source);
|
||||||
|
JsonUtilTest.ClassWithDefaultValue instance = JsonUtil.DeserializeFromString<JsonUtilTest.ClassWithDefaultValue
|
||||||
|
>(jsonString);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithDefaultValueObject("some small string", 8, 26.0), instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeWithUnknownPropertiesStreamTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithUnknownProperties.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(source)) {
|
||||||
|
JsonUtilTest.ClassWithDefaultValue instance = JsonUtil.DeserializeFromStream<JsonUtilTest.ClassWithDefaultValue
|
||||||
|
>(inputStream);
|
||||||
|
NUnit.Framework.Assert.IsNotNull(instance);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithDefaultValueObject("some small string", 8, 26.0), instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeWithDefaultValueTypeReferenceStreamTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithDefaultValue.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(source)) {
|
||||||
|
JsonUtilTest.ClassWithDefaultValue instance = JsonUtil.DeserializeFromStream<JsonUtilTest.ClassWithDefaultValue
|
||||||
|
>(inputStream);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithDefaultValueObject(null, 2, 5.0), instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void DeserializeWithDefaultValueTypeReferenceStringTest() {
|
||||||
|
String source = SOURCE_FOLDER + "classWithDefaultValue.json";
|
||||||
|
String jsonString = GetJsonStringFromFile(source);
|
||||||
|
JsonUtilTest.ClassWithDefaultValue instance = JsonUtil.DeserializeFromString<JsonUtilTest.ClassWithDefaultValue
|
||||||
|
>(jsonString);
|
||||||
|
NUnit.Framework.Assert.AreEqual(CreateClassWithDefaultValueObject(null, 2, 5.0), instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String GetJsonStringFromFile(String pathToFile) {
|
||||||
|
byte[] fileBytes = File.ReadAllBytes(System.IO.Path.Combine(pathToFile));
|
||||||
|
// Use String(byte[]) because there is autoporting for this
|
||||||
|
// construction by sharpen by call JavaUtil#GetStringForBytes
|
||||||
|
return TSpdf.Commons.Utils.JavaUtil.GetStringForBytes(fileBytes, System.Text.Encoding.UTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MemoryStream ConvertInputStreamToOutput(Stream inputStream) {
|
||||||
|
MemoryStream result = new MemoryStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int length;
|
||||||
|
while ((length = inputStream.Read(buffer)) != -1) {
|
||||||
|
result.Write(buffer, 0, length);
|
||||||
|
}
|
||||||
|
result.Flush();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JsonUtilTest.ComplexStructure CreateComplexStructureObject() {
|
||||||
|
JsonUtilTest.ComplexStructure complexStructure = new JsonUtilTest.ComplexStructure();
|
||||||
|
complexStructure.map.Put("FirstMapKey", 15);
|
||||||
|
complexStructure.map.Put("SecondMapKey", 8);
|
||||||
|
complexStructure.str = "StringFieldValue";
|
||||||
|
JsonUtilTest.ChildInComplexStructure child = new JsonUtilTest.ChildInComplexStructure();
|
||||||
|
child.arrayStr = new String[] { "someStr1", "someStr2" };
|
||||||
|
JsonUtilTest.GrandsonComplexStructure grandson = new JsonUtilTest.GrandsonComplexStructure();
|
||||||
|
grandson.integer = 13;
|
||||||
|
grandson.name = "someName";
|
||||||
|
child.grandsons = new JsonUtilTest.GrandsonComplexStructure[] { grandson, new JsonUtilTest.GrandsonComplexStructure
|
||||||
|
() };
|
||||||
|
complexStructure.childsMap.Put("ChildMapkey", child);
|
||||||
|
complexStructure.childsMap.Put("ChildMapKey2", new JsonUtilTest.ChildInComplexStructure());
|
||||||
|
return complexStructure;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JsonUtilTest.ClassWithDefaultValue CreateClassWithDefaultValueObject(String firstString, int
|
||||||
|
value, double? doubleValue) {
|
||||||
|
return new JsonUtilTest.ClassWithDefaultValue(firstString, value, doubleValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JsonUtilTest.ClassWithEnum CreateClassWithEnumObject() {
|
||||||
|
JsonUtilTest.ClassWithEnum classWithEnum = new JsonUtilTest.ClassWithEnum();
|
||||||
|
classWithEnum.enumArray = new JsonUtilTest.SomeEnum[] { JsonUtilTest.SomeEnum.FIRST_VALUE, JsonUtilTest.SomeEnum
|
||||||
|
.FIRST_VALUE, JsonUtilTest.SomeEnum.SECOND_VALUE };
|
||||||
|
classWithEnum.firstValue = JsonUtilTest.SomeEnum.SECOND_VALUE;
|
||||||
|
return classWithEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String[] CreateStringWithLineBreaks() {
|
||||||
|
return new String[] { "String\n\rtest", " \n \t" };
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ComplexStructure {
|
||||||
|
public IDictionary<String, int?> map = new LinkedDictionary<String, int?>();
|
||||||
|
|
||||||
|
public String str = "";
|
||||||
|
|
||||||
|
public IDictionary<String, JsonUtilTest.ChildInComplexStructure> childsMap = new LinkedDictionary<String,
|
||||||
|
JsonUtilTest.ChildInComplexStructure>();
|
||||||
|
|
||||||
|
public override bool Equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || GetType() != o.GetType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JsonUtilTest.ComplexStructure that = (JsonUtilTest.ComplexStructure)o;
|
||||||
|
return MapUtil.Equals(map, that.map) && Object.Equals(str, that.str) && MapUtil.Equals(childsMap, that.childsMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int result = map != null ? MapUtil.GetHashCode(map) : 0;
|
||||||
|
result = 31 * result + (str != null ? str.GetHashCode() : 0);
|
||||||
|
result = 31 * result + (childsMap != null ? MapUtil.GetHashCode(childsMap) : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChildInComplexStructure {
|
||||||
|
public String[] arrayStr = new String[] { "" };
|
||||||
|
|
||||||
|
public JsonUtilTest.GrandsonComplexStructure[] grandsons = new JsonUtilTest.GrandsonComplexStructure[] { new
|
||||||
|
JsonUtilTest.GrandsonComplexStructure() };
|
||||||
|
|
||||||
|
public override bool Equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || GetType() != o.GetType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JsonUtilTest.ChildInComplexStructure that = (JsonUtilTest.ChildInComplexStructure)o;
|
||||||
|
return JavaUtil.ArraysEquals(arrayStr, that.arrayStr) && JavaUtil.ArraysEquals(grandsons, that.grandsons);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int result = JavaUtil.ArraysHashCode(arrayStr);
|
||||||
|
result = 31 * result + JavaUtil.ArraysHashCode(grandsons);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class GrandsonComplexStructure {
|
||||||
|
public int integer = 0;
|
||||||
|
|
||||||
|
public String name = "";
|
||||||
|
|
||||||
|
public override bool Equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || GetType() != o.GetType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JsonUtilTest.GrandsonComplexStructure that = (JsonUtilTest.GrandsonComplexStructure)o;
|
||||||
|
return integer == that.integer && Object.Equals(name, that.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int result = integer;
|
||||||
|
result = 31 * result + (name != null ? name.GetHashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ClassWithEnum {
|
||||||
|
public JsonUtilTest.SomeEnum firstValue;
|
||||||
|
|
||||||
|
public JsonUtilTest.SomeEnum[] enumArray = new JsonUtilTest.SomeEnum[] { };
|
||||||
|
|
||||||
|
public override bool Equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || GetType() != o.GetType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JsonUtilTest.ClassWithEnum that = (JsonUtilTest.ClassWithEnum)o;
|
||||||
|
return firstValue == that.firstValue && JavaUtil.ArraysEquals(enumArray, that.enumArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int result = JavaUtil.ArraysHashCode(firstValue);
|
||||||
|
result = 31 * result + JavaUtil.ArraysHashCode(enumArray);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum SomeEnum {
|
||||||
|
FIRST_VALUE,
|
||||||
|
SECOND_VALUE,
|
||||||
|
THIRD_VALUE
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ClassWithDefaultValue {
|
||||||
|
public String firstString = "defaultValue";
|
||||||
|
|
||||||
|
public int? integer = 3;
|
||||||
|
|
||||||
|
public double? doubleValue = 0.0;
|
||||||
|
|
||||||
|
public ClassWithDefaultValue(String firstString, int? integer, double? doubleValue) {
|
||||||
|
if (firstString != null) {
|
||||||
|
this.firstString = firstString;
|
||||||
|
}
|
||||||
|
if (integer != null) {
|
||||||
|
this.integer = integer;
|
||||||
|
}
|
||||||
|
this.doubleValue = doubleValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || GetType() != o.GetType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JsonUtilTest.ClassWithDefaultValue that = (JsonUtilTest.ClassWithDefaultValue)o;
|
||||||
|
return Object.Equals(firstString, that.firstString) && Object.Equals(integer, that.integer) && Object.Equals
|
||||||
|
(doubleValue, that.doubleValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int result = (firstString == null ? 0 : firstString.GetHashCode());
|
||||||
|
result = 31 * result + (integer == null ? 0 : integer.GetHashCode());
|
||||||
|
result = 31 * result + (doubleValue == null ? 0 : doubleValue.GetHashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using TSpdf.Test;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class JsonUtilWithNewtonsoftTest : ExtendedTSpdfTest {
|
||||||
|
private static Func<JsonSerializerSettings> DEFAULT_JSON_CONVERTER_SETTINGS;
|
||||||
|
|
||||||
|
private static readonly String SOURCE_FOLDER = TSpdf.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
|
||||||
|
.CurrentContext.TestDirectory) + "/resources/TSpdf/commons/utils/JsonUtilTest/";
|
||||||
|
|
||||||
|
[NUnit.Framework.SetUp]
|
||||||
|
public virtual void SetUpHandler() {
|
||||||
|
DEFAULT_JSON_CONVERTER_SETTINGS = JsonConvert.DefaultSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TearDown]
|
||||||
|
public virtual void ResetHandler() {
|
||||||
|
JsonConvert.DefaultSettings = DEFAULT_JSON_CONVERTER_SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TryToOverrideDefaultSerializationSettingForSerializeToStringTest() {
|
||||||
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
TypeNameHandling = TypeNameHandling.All
|
||||||
|
};
|
||||||
|
String cmp = SOURCE_FOLDER + "classWithEnum.json";
|
||||||
|
ClassWithEnum classWithEnum = CreateClassWithEnumObject();
|
||||||
|
String resultString = JsonUtil.SerializeToString(classWithEnum);
|
||||||
|
String cmpString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(cmpString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TryToOverrideDefaultSerializationSettingForSerializeToStreamTest() {
|
||||||
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
TypeNameHandling = TypeNameHandling.Objects
|
||||||
|
};
|
||||||
|
String path = SOURCE_FOLDER + "classWithEnum.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(path)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToStream(serializationResult, CreateClassWithEnumObject());
|
||||||
|
serializationResult.Flush();
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TryToOverrideDefaultSerializationSettingForSerializeToMinimalStringTest() {
|
||||||
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
TypeNameHandling = TypeNameHandling.Arrays
|
||||||
|
};
|
||||||
|
String cmp = SOURCE_FOLDER + "minimalClassWithEnum.json";
|
||||||
|
ClassWithEnum classWithEnum = CreateClassWithEnumObject();
|
||||||
|
String resultString = JsonUtil.SerializeToMinimalString(classWithEnum);
|
||||||
|
String compareString = GetJsonStringFromFile(cmp);
|
||||||
|
NUnit.Framework.Assert.IsTrue(JsonUtil.AreTwoJsonObjectEquals(compareString, resultString));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TryToOverrideDefaultSerializationSettingForSerializeToMinimalStreamTest() {
|
||||||
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
TypeNameHandling = TypeNameHandling.All
|
||||||
|
};
|
||||||
|
String path = SOURCE_FOLDER + "minimalClassWithEnum.json";
|
||||||
|
using (Stream inputStream = FileUtil.GetInputStreamForFile(path)) {
|
||||||
|
using (MemoryStream baos = ConvertInputStreamToOutput(inputStream)) {
|
||||||
|
using (MemoryStream serializationResult = new MemoryStream()) {
|
||||||
|
JsonUtil.SerializeToMinimalStream(serializationResult, CreateClassWithEnumObject());
|
||||||
|
serializationResult.Flush();
|
||||||
|
NUnit.Framework.Assert.AreEqual(baos.ToArray(), serializationResult.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String GetJsonStringFromFile(String pathToFile) {
|
||||||
|
byte[] fileBytes = File.ReadAllBytes(System.IO.Path.Combine(pathToFile));
|
||||||
|
// Use String(byte[]) because there is autoporting for this
|
||||||
|
// construction by sharpen by call JavaUtil#GetStringForBytes
|
||||||
|
return TSpdf.Commons.Utils.JavaUtil.GetStringForBytes(fileBytes, System.Text.Encoding.UTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MemoryStream ConvertInputStreamToOutput(Stream inputStream) {
|
||||||
|
MemoryStream result = new MemoryStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int length;
|
||||||
|
while ((length = inputStream.Read(buffer)) != -1) {
|
||||||
|
result.Write(buffer, 0, length);
|
||||||
|
}
|
||||||
|
result.Flush();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClassWithEnum CreateClassWithEnumObject() {
|
||||||
|
ClassWithEnum classWithEnum = new ClassWithEnum();
|
||||||
|
classWithEnum.enumArray = new SomeEnum[] { SomeEnum.FIRST_VALUE, SomeEnum
|
||||||
|
.FIRST_VALUE, SomeEnum.SECOND_VALUE };
|
||||||
|
classWithEnum.firstValue = SomeEnum.SECOND_VALUE;
|
||||||
|
return classWithEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ClassWithEnum {
|
||||||
|
public SomeEnum firstValue;
|
||||||
|
|
||||||
|
public SomeEnum[] enumArray = new SomeEnum[] { };
|
||||||
|
|
||||||
|
public override bool Equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || GetType() != o.GetType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ClassWithEnum that = (ClassWithEnum)o;
|
||||||
|
return firstValue == that.firstValue && JavaUtil.ArraysEquals(enumArray, that.enumArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int result = JavaUtil.ArraysHashCode(firstValue);
|
||||||
|
result = 31 * result + JavaUtil.ArraysHashCode(enumArray);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum SomeEnum {
|
||||||
|
FIRST_VALUE,
|
||||||
|
SECOND_VALUE,
|
||||||
|
THIRD_VALUE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class MapUtilTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullMapsAreEqualTest() {
|
||||||
|
NUnit.Framework.Assert.IsTrue(MapUtil.Equals(null, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullMapIsNotEqualToEmptyMapTest() {
|
||||||
|
NUnit.Framework.Assert.IsFalse(MapUtil.Equals(new Dictionary<String, String>(), null));
|
||||||
|
NUnit.Framework.Assert.IsFalse(MapUtil.Equals(null, new Dictionary<String, String>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MapsOfDifferentTypesAreNotEqualTest() {
|
||||||
|
NUnit.Framework.Assert.IsFalse(MapUtil.Equals(new Dictionary<String, String>(), new SortedDictionary<String
|
||||||
|
, String>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MapsOfDifferentSizeAreNotEqualTest() {
|
||||||
|
IDictionary<String, String> m1 = new Dictionary<String, String>();
|
||||||
|
m1.Put("m1", "m1");
|
||||||
|
IDictionary<String, String> m2 = new Dictionary<String, String>();
|
||||||
|
m2.Put("m1", "m1");
|
||||||
|
m2.Put("m2", "m2");
|
||||||
|
NUnit.Framework.Assert.IsFalse(MapUtil.Equals(m1, m2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullValueInMapTest() {
|
||||||
|
IDictionary<String, String> m1 = JavaCollectionsUtil.SingletonMap<String, String>("nullKey", null);
|
||||||
|
IDictionary<String, String> m2 = JavaCollectionsUtil.SingletonMap("notNullKey", "notNull");
|
||||||
|
NUnit.Framework.Assert.IsFalse(MapUtil.Equals(m1, m2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MapsWithDifferentKeysAreNotEqualTest() {
|
||||||
|
IDictionary<String, String> m1 = new Dictionary<String, String>();
|
||||||
|
m1.Put("m1", "value");
|
||||||
|
IDictionary<String, String> m2 = new Dictionary<String, String>();
|
||||||
|
m2.Put("m2", "value");
|
||||||
|
NUnit.Framework.Assert.IsFalse(MapUtil.Equals(m1, m2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MapsWithDifferentValuesAreNotEqualTest() {
|
||||||
|
IDictionary<String, String> m1 = new Dictionary<String, String>();
|
||||||
|
m1.Put("key", "m1");
|
||||||
|
IDictionary<String, String> m2 = new Dictionary<String, String>();
|
||||||
|
m2.Put("key", "m2");
|
||||||
|
NUnit.Framework.Assert.IsFalse(MapUtil.Equals(m1, m2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void EqualArraysTest() {
|
||||||
|
IDictionary<String, String> m1 = new Dictionary<String, String>();
|
||||||
|
m1.Put("key", "value");
|
||||||
|
IDictionary<String, String> m2 = new Dictionary<String, String>();
|
||||||
|
m2.Put("key", "value");
|
||||||
|
NUnit.Framework.Assert.IsTrue(MapUtil.Equals(m1, m2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PutIfNotNullTest() {
|
||||||
|
IDictionary<String, String> m1 = new Dictionary<String, String>();
|
||||||
|
MapUtil.PutIfNotNull(m1, "key", null);
|
||||||
|
NUnit.Framework.Assert.IsTrue(m1.IsEmpty());
|
||||||
|
MapUtil.PutIfNotNull(m1, "key", "value");
|
||||||
|
NUnit.Framework.Assert.IsFalse(m1.IsEmpty());
|
||||||
|
NUnit.Framework.Assert.AreEqual("value", m1.Get("key"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullMapsEqualEqualHashCodeTest() {
|
||||||
|
NUnit.Framework.Assert.AreEqual(MapUtil.GetHashCode((IDictionary<String, String>)null), MapUtil.GetHashCode
|
||||||
|
((IDictionary<String, String>)null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void NullMapEmptyMapDiffHashCodeTest() {
|
||||||
|
NUnit.Framework.Assert.AreEqual(MapUtil.GetHashCode((IDictionary<String, String>)null), MapUtil.GetHashCode
|
||||||
|
(new Dictionary<String, String>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MapsOfDifferentTypesHashCodeTest() {
|
||||||
|
NUnit.Framework.Assert.AreEqual(MapUtil.GetHashCode(new SortedDictionary<Object, Object>()), MapUtil.GetHashCode
|
||||||
|
(new Dictionary<String, String>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void EqualMapsHashCodeTest() {
|
||||||
|
IDictionary<String, String> m1 = new Dictionary<String, String>();
|
||||||
|
m1.Put("key", "value");
|
||||||
|
IDictionary<String, String> m2 = new Dictionary<String, String>();
|
||||||
|
m2.Put("key", "value");
|
||||||
|
NUnit.Framework.Assert.AreEqual(MapUtil.GetHashCode(m1), MapUtil.GetHashCode(m2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void MapsMergeTest() {
|
||||||
|
IDictionary<int, int?> destination = new Dictionary<int, int?>();
|
||||||
|
destination.Put(1, 5);
|
||||||
|
destination.Put(2, 5);
|
||||||
|
destination.Put(4, 5);
|
||||||
|
IDictionary<int, int?> source = new Dictionary<int, int?>();
|
||||||
|
source.Put(1, 10);
|
||||||
|
source.Put(2, 10);
|
||||||
|
source.Put(3, 10);
|
||||||
|
MapUtil.Merge(destination, JavaCollectionsUtil.UnmodifiableMap(source), (d, s) => d + s);
|
||||||
|
IDictionary<int, int?> expectedMap = new Dictionary<int, int?>();
|
||||||
|
expectedMap.Put(1, 15);
|
||||||
|
expectedMap.Put(2, 15);
|
||||||
|
expectedMap.Put(3, 10);
|
||||||
|
expectedMap.Put(4, 5);
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedMap, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void SameMapsMergeTest() {
|
||||||
|
IDictionary<int, int?> map = new Dictionary<int, int?>();
|
||||||
|
map.Put(1, 5);
|
||||||
|
map.Put(2, 5);
|
||||||
|
map.Put(4, 5);
|
||||||
|
IDictionary<int, int?> expectedMap = new Dictionary<int, int?>(map);
|
||||||
|
MapUtil.Merge(map, map, (d, s) => d + s);
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedMap, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
[NUnit.Framework.TestFixtureSource("DataSourceTestFixtureData")]
|
||||||
|
public class MessageFormatUtilTest : ExtendedTSpdfTest {
|
||||||
|
private String expectedResult;
|
||||||
|
|
||||||
|
private String pattern;
|
||||||
|
|
||||||
|
private Object[] arguments;
|
||||||
|
|
||||||
|
public MessageFormatUtilTest(Object expectedResult, Object pattern, Object arguments, Object name) {
|
||||||
|
this.expectedResult = (String)expectedResult;
|
||||||
|
this.pattern = (String)pattern;
|
||||||
|
this.arguments = (Object[])arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageFormatUtilTest(Object[] array)
|
||||||
|
: this(array[0], array[1], array[2], array[3]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<Object[]> DataSource() {
|
||||||
|
return JavaUtil.ArraysAsList(new Object[][] { new Object[] { "Plain message with params 1 test", "Plain message with params {0} {1}"
|
||||||
|
, new Object[] { 1, "test" }, "test with simple params" }, new Object[] { "Message with 'single quotes'"
|
||||||
|
, "Message with 'single quotes'", new Object[0], "test with single quotes" }, new Object[] { "Message with ''doubled single quotes''"
|
||||||
|
, "Message with ''doubled single quotes''", new Object[0], "test with doubled single quotes" }, new Object
|
||||||
|
[] { "Message with {curly braces} and a parameter {I'm between curly braces too}", "Message with {{curly braces}} and a parameter {{{0}}}"
|
||||||
|
, new Object[] { "I'm between curly braces too" }, "Test with curly braces" }, new Object[] { "'{value}'"
|
||||||
|
, "'{{{0}}}'", new Object[] { "value" }, "Mix om multiple brackets and quotes 1" }, new Object[] { "'value'"
|
||||||
|
, "'{0}'", new Object[] { "value" }, "Mix of brackets and quotes" }, new Object[] { "{'0'}", "{{'0'}}"
|
||||||
|
, new Object[0], "Mix of multiple brackets and quotes 2" }, new Object[] { "single opening brace {0 test"
|
||||||
|
, "single opening brace {{0 test", new Object[0], "Test single opening brace" }, new Object[] { "single closing brace 0} test"
|
||||||
|
, "single closing brace 0}} test", new Object[0], "Test single closing brace" }, new Object[] { "single opening + closing brace { test }"
|
||||||
|
, "single opening + closing brace {{ {0} }}", new Object[] { "test" }, "Test single opening and closing brace"
|
||||||
|
} });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ICollection<NUnit.Framework.TestFixtureData> DataSourceTestFixtureData() {
|
||||||
|
return DataSource().Select(array => new NUnit.Framework.TestFixtureData(array)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void TestFormatting() {
|
||||||
|
NUnit.Framework.Assert.AreEqual(expectedResult, MessageFormatUtil.Format(pattern, arguments));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is offered under a commercial and under the AGPL license.
|
||||||
|
For commercial licensing, contact us at https://TSpdfpdf.com/sales. For AGPL licensing, see below.
|
||||||
|
|
||||||
|
AGPL licensing:
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class ProcessInfoTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetExitCodeTest() {
|
||||||
|
int exitCode = 1;
|
||||||
|
ProcessInfo processInfo = new ProcessInfo(exitCode, null, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual(exitCode, processInfo.GetExitCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetProcessStdOutput() {
|
||||||
|
String stdOutput = "output";
|
||||||
|
ProcessInfo processInfo = new ProcessInfo(0, stdOutput, null);
|
||||||
|
NUnit.Framework.Assert.AreEqual(stdOutput, processInfo.GetProcessStdOutput());
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void GetProcessErrOutput() {
|
||||||
|
String stdOutput = "output";
|
||||||
|
ProcessInfo processInfo = new ProcessInfo(0, null, stdOutput);
|
||||||
|
NUnit.Framework.Assert.AreEqual(stdOutput, processInfo.GetProcessErrOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
This file is part of the TSpdf (R) project.
|
||||||
|
Copyright (c) 1987-2023 TSpdf
|
||||||
|
Authors: TSpdf Software.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License version 3
|
||||||
|
as published by the Free Software Foundation with the addition of the
|
||||||
|
following permission added to Section 15 as permitted in Section 7(a):
|
||||||
|
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
||||||
|
TSpdf GROUP. TSpdf GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||||
|
OF THIRD PARTY RIGHTS
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, see http://www.gnu.org/licenses or write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA, 02110-1301 USA, or download the license from the following URL:
|
||||||
|
http://TSpdfpdf.com/terms-of-use/
|
||||||
|
|
||||||
|
The interactive user interfaces in modified source and object code versions
|
||||||
|
of this program must display Appropriate Legal Notices, as required under
|
||||||
|
Section 5 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
In accordance with Section 7(b) of the GNU Affero General Public License,
|
||||||
|
a covered work must retain the producer line in every PDF that is created
|
||||||
|
or manipulated using TSpdf.
|
||||||
|
|
||||||
|
You can be released from the requirements of the license by purchasing
|
||||||
|
a commercial license. Buying such a license is mandatory as soon as you
|
||||||
|
develop commercial activities involving the TSpdf software without
|
||||||
|
disclosing the source code of your own applications.
|
||||||
|
These activities include: offering paid services to customers as an ASP,
|
||||||
|
serving PDFs on the fly in a web application, shipping TSpdf with a closed
|
||||||
|
source product.
|
||||||
|
|
||||||
|
For more information, please contact TSpdf Software Corp. at this
|
||||||
|
address: sales@TSpdfpdf.com
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using TSpdf.Test;
|
||||||
|
|
||||||
|
namespace TSpdf.Commons.Utils {
|
||||||
|
/// <summary>At the moment there is no StringUtil class in Java, but there is one in C# and we are testing</summary>
|
||||||
|
[NUnit.Framework.Category("UnitTest")]
|
||||||
|
public class StringUtilTest : ExtendedTSpdfTest {
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PatternSplitTest01() {
|
||||||
|
// Android-Conversion-Ignore-Test (TODO DEVSIX-6457 fix different behavior of Pattern.split method)
|
||||||
|
// Pattern.split in Java works differently compared to Regex.Split in C#
|
||||||
|
// In C#, empty strings are possible at the beginning of the resultant array for non-capturing groups in split regex
|
||||||
|
// Thus, in C# we use a separate utility for splitting to align the implementation with Java
|
||||||
|
// This test verifies that the resultant behavior is the same
|
||||||
|
Regex pattern = TSpdf.Commons.Utils.StringUtil.RegexCompile("(?=[ab])");
|
||||||
|
String source = "a01aa78ab89b";
|
||||||
|
String[] expected = new String[] { "a01", "a", "a78", "a", "b89", "b" };
|
||||||
|
String[] result = TSpdf.Commons.Utils.StringUtil.Split(pattern, source);
|
||||||
|
NUnit.Framework.Assert.AreEqual(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void PatternSplitTest02() {
|
||||||
|
Regex pattern = TSpdf.Commons.Utils.StringUtil.RegexCompile("(?=[ab])");
|
||||||
|
String source = "";
|
||||||
|
String[] expected = new String[] { "" };
|
||||||
|
String[] result = TSpdf.Commons.Utils.StringUtil.Split(pattern, source);
|
||||||
|
NUnit.Framework.Assert.AreEqual(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void StringSplitTest01() {
|
||||||
|
// Android-Conversion-Ignore-Test (TODO DEVSIX-6457 fix different behavior of Pattern.split method)
|
||||||
|
String source = "a01aa78ab89b";
|
||||||
|
String[] expected = new String[] { "a01", "a", "a78", "a", "b89", "b" };
|
||||||
|
String[] result = TSpdf.Commons.Utils.StringUtil.Split(source, "(?=[ab])");
|
||||||
|
NUnit.Framework.Assert.AreEqual(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.Test]
|
||||||
|
public virtual void StringSplitTest02() {
|
||||||
|
String source = "";
|
||||||
|
String[] expected = new String[] { "" };
|
||||||
|
String[] result = TSpdf.Commons.Utils.StringUtil.Split(source, "(?=[ab])");
|
||||||
|
NUnit.Framework.Assert.AreEqual(expected, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user