11/*
22This file is part of the iText (R) project.
3- Copyright (c) 1998-2021 iText Group NV
3+ Copyright (c) 1998-2022 iText Group NV
44Authors: iText Software.
55
66This program is free software; you can redistribute it and/or modify
@@ -50,21 +50,21 @@ source product.
5050
5151namespace iText . Barcodes {
5252 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
5454 . CurrentContext . TestDirectory ) + "/resources/itext/barcodes/" ;
5555
56- public static readonly String destinationFolder = NUnit . Framework . TestContext . CurrentContext . TestDirectory
56+ private static readonly String DESTINATION_FOLDER = NUnit . Framework . TestContext . CurrentContext . TestDirectory
5757 + "/test/itext/barcodes/Codabar/" ;
5858
5959 [ NUnit . Framework . OneTimeSetUp ]
6060 public static void BeforeClass ( ) {
61- CreateDestinationFolder ( destinationFolder ) ;
61+ CreateDestinationFolder ( DESTINATION_FOLDER ) ;
6262 }
6363
6464 [ NUnit . Framework . Test ]
6565 public virtual void Barcode01Test ( ) {
6666 String filename = "codabar.pdf" ;
67- PdfWriter writer = new PdfWriter ( destinationFolder + filename ) ;
67+ PdfWriter writer = new PdfWriter ( DESTINATION_FOLDER + filename ) ;
6868 PdfDocument document = new PdfDocument ( writer ) ;
6969 PdfPage page = document . AddNewPage ( ) ;
7070 PdfCanvas canvas = new PdfCanvas ( page ) ;
@@ -73,52 +73,48 @@ public virtual void Barcode01Test() {
7373 codabar . SetStartStopText ( true ) ;
7474 codabar . PlaceBarcode ( canvas , null , null ) ;
7575 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_" ) ) ;
7878 }
7979
8080 [ NUnit . Framework . Test ]
8181 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 ) ;
8988 }
9089
9190 [ NUnit . Framework . Test ]
9291 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 ) ;
10098 }
10199
102100 [ NUnit . Framework . Test ]
103101 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 ) ;
111108 }
112109
113110 [ NUnit . Framework . Test ]
114111 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 ) ;
122118 }
123119 }
124120}
0 commit comments