1
1
/*
2
2
This file is part of the iText (R) project.
3
- Copyright (c) 1998-2021 iText Group NV
3
+ Copyright (c) 1998-2022 iText Group NV
4
4
Authors: iText Software.
5
5
6
6
This program is free software; you can redistribute it and/or modify
@@ -50,21 +50,21 @@ source product.
50
50
51
51
namespace iText . Barcodes {
52
52
public class BarcodeCodabarTest : ExtendedITextTest {
53
- public static readonly String sourceFolder = iText . Test . TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext
53
+ private static readonly String SOURCE_FOLDER = iText . Test . TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext
54
54
. CurrentContext . TestDirectory ) + "/resources/itext/barcodes/" ;
55
55
56
- public static readonly String destinationFolder = NUnit . Framework . TestContext . CurrentContext . TestDirectory
56
+ private static readonly String DESTINATION_FOLDER = NUnit . Framework . TestContext . CurrentContext . TestDirectory
57
57
+ "/test/itext/barcodes/Codabar/" ;
58
58
59
59
[ NUnit . Framework . OneTimeSetUp ]
60
60
public static void BeforeClass ( ) {
61
- CreateDestinationFolder ( destinationFolder ) ;
61
+ CreateDestinationFolder ( DESTINATION_FOLDER ) ;
62
62
}
63
63
64
64
[ NUnit . Framework . Test ]
65
65
public virtual void Barcode01Test ( ) {
66
66
String filename = "codabar.pdf" ;
67
- PdfWriter writer = new PdfWriter ( destinationFolder + filename ) ;
67
+ PdfWriter writer = new PdfWriter ( DESTINATION_FOLDER + filename ) ;
68
68
PdfDocument document = new PdfDocument ( writer ) ;
69
69
PdfPage page = document . AddNewPage ( ) ;
70
70
PdfCanvas canvas = new PdfCanvas ( page ) ;
@@ -73,52 +73,48 @@ public virtual void Barcode01Test() {
73
73
codabar . SetStartStopText ( true ) ;
74
74
codabar . PlaceBarcode ( canvas , null , null ) ;
75
75
document . Close ( ) ;
76
- NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + filename , sourceFolder
77
- + "cmp_" + filename , destinationFolder , "diff_" ) ) ;
76
+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( DESTINATION_FOLDER + filename , SOURCE_FOLDER
77
+ + "cmp_" + filename , DESTINATION_FOLDER , "diff_" ) ) ;
78
78
}
79
79
80
80
[ NUnit . Framework . Test ]
81
81
public virtual void BarcodeHasNoAbcdAsStartCharacterTest ( ) {
82
- NUnit . Framework . Assert . That ( ( ) => {
83
- PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
84
- BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
85
- BarcodeCodabar . GetBarsCodabar ( "qbcd" ) ;
86
- }
87
- , NUnit . Framework . Throws . InstanceOf < ArgumentException > ( ) . With . Message . EqualTo ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER ) )
88
- ;
82
+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
83
+ BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
84
+ Exception exception = NUnit . Framework . Assert . Catch ( typeof ( ArgumentException ) , ( ) => BarcodeCodabar . GetBarsCodabar
85
+ ( "qbcd" ) ) ;
86
+ NUnit . Framework . Assert . AreEqual ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER
87
+ , exception . Message ) ;
89
88
}
90
89
91
90
[ NUnit . Framework . Test ]
92
91
public virtual void BarcodeHasNoAbcdAsStopCharacterTest ( ) {
93
- NUnit . Framework . Assert . That ( ( ) => {
94
- PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
95
- BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
96
- BarcodeCodabar . GetBarsCodabar ( "abcf" ) ;
97
- }
98
- , NUnit . Framework . Throws . InstanceOf < ArgumentException > ( ) . With . Message . EqualTo ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER ) )
99
- ;
92
+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
93
+ BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
94
+ Exception exception = NUnit . Framework . Assert . Catch ( typeof ( ArgumentException ) , ( ) => BarcodeCodabar . GetBarsCodabar
95
+ ( "abcf" ) ) ;
96
+ NUnit . Framework . Assert . AreEqual ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER
97
+ , exception . Message ) ;
100
98
}
101
99
102
100
[ NUnit . Framework . Test ]
103
101
public virtual void BarcodeHasNoAbcdAsStartAndStopCharacterTest ( ) {
104
- NUnit . Framework . Assert . That ( ( ) => {
105
- PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
106
- BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
107
- BarcodeCodabar . GetBarsCodabar ( "qbcq" ) ;
108
- }
109
- , NUnit . Framework . Throws . InstanceOf < ArgumentException > ( ) . With . Message . EqualTo ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER ) )
110
- ;
102
+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
103
+ BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
104
+ Exception exception = NUnit . Framework . Assert . Catch ( typeof ( ArgumentException ) , ( ) => BarcodeCodabar . GetBarsCodabar
105
+ ( "qbcq" ) ) ;
106
+ NUnit . Framework . Assert . AreEqual ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER
107
+ , exception . Message ) ;
111
108
}
112
109
113
110
[ NUnit . Framework . Test ]
114
111
public virtual void BarcodeHasNoStartAndStopCharacterTest ( ) {
115
- NUnit . Framework . Assert . That ( ( ) => {
116
- PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
117
- BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
118
- BarcodeCodabar . GetBarsCodabar ( "" ) ;
119
- }
120
- , NUnit . Framework . Throws . InstanceOf < ArgumentException > ( ) . With . Message . EqualTo ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER ) )
121
- ;
112
+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( new MemoryStream ( ) ) ) ;
113
+ BarcodeCodabar codabar = new BarcodeCodabar ( pdfDocument ) ;
114
+ Exception exception = NUnit . Framework . Assert . Catch ( typeof ( ArgumentException ) , ( ) => BarcodeCodabar . GetBarsCodabar
115
+ ( "" ) ) ;
116
+ NUnit . Framework . Assert . AreEqual ( BarcodeExceptionMessageConstant . CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER
117
+ , exception . Message ) ;
122
118
}
123
119
}
124
120
}
0 commit comments