@@ -15,16 +15,6 @@ namespace QRCoderTests
15
15
public class SvgQRCodeRendererTests
16
16
{
17
17
18
- private string GetAssemblyPath ( )
19
- {
20
- return
21
- #if NET5_0
22
- AppDomain . CurrentDomain . BaseDirectory ;
23
- #else
24
- Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . CodeBase ) . Replace ( "file:\\ " , "" ) ;
25
- #endif
26
- }
27
-
28
18
[ Fact ]
29
19
[ Category ( "QRRenderer/SvgQRCode" ) ]
30
20
public void can_render_svg_qrcode_simple ( )
@@ -113,7 +103,7 @@ public void can_render_svg_qrcode_with_png_logo_bitmap()
113
103
var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
114
104
115
105
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
116
- var logoBitmap = ( Bitmap ) Image . FromFile ( GetAssemblyPath ( ) + "\\ assets\\ noun_software engineer_2909346.png" ) ;
106
+ var logoBitmap = ( Bitmap ) Image . FromFile ( HelperFunctions . GetAssemblyPath ( ) + "\\ assets\\ noun_software engineer_2909346.png" ) ;
117
107
var logoObj = new SvgQRCode . SvgLogo ( iconRasterized : logoBitmap , 15 ) ;
118
108
logoObj . GetMediaType ( ) . ShouldBe < SvgQRCode . SvgLogo . MediaType > ( SvgQRCode . SvgLogo . MediaType . PNG ) ;
119
109
@@ -122,6 +112,44 @@ public void can_render_svg_qrcode_with_png_logo_bitmap()
122
112
var result = HelperFunctions . StringToHash ( svg ) ;
123
113
result . ShouldBe ( "78e02e8ba415f15817d5ed88c4afca31" ) ;
124
114
}
115
+
116
+ [ Fact ]
117
+ [ Category ( "QRRenderer/SvgQRCode" ) ]
118
+ public void can_render_svg_qrcode_with_png_logo_bitmap_without_background ( )
119
+ {
120
+ //Create QR code
121
+ var gen = new QRCodeGenerator ( ) ;
122
+ var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
123
+
124
+ //Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
125
+ var logoBitmap = ( Bitmap ) Image . FromFile ( HelperFunctions . GetAssemblyPath ( ) + "\\ assets\\ noun_software engineer_2909346.png" ) ;
126
+ var logoObj = new SvgQRCode . SvgLogo ( iconRasterized : logoBitmap , 15 , false ) ;
127
+ logoObj . GetMediaType ( ) . ShouldBe < SvgQRCode . SvgLogo . MediaType > ( SvgQRCode . SvgLogo . MediaType . PNG ) ;
128
+
129
+ var svg = new SvgQRCode ( data ) . GetGraphic ( 10 , Color . DarkGray , Color . White , logo : logoObj ) ;
130
+
131
+ var result = HelperFunctions . StringToHash ( svg ) ;
132
+ result . ShouldBe ( "f221b2baecc2883f8e8ae54f12ba701b" ) ;
133
+ }
134
+
135
+ [ Fact ]
136
+ [ Category ( "QRRenderer/SvgQRCode" ) ]
137
+ public void can_render_svg_qrcode_with_png_logo_bitmap_without_quietzones ( )
138
+ {
139
+ //Create QR code
140
+ var gen = new QRCodeGenerator ( ) ;
141
+ var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
142
+
143
+ //Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
144
+ var logoBitmap = ( Bitmap ) Image . FromFile ( HelperFunctions . GetAssemblyPath ( ) + "\\ assets\\ noun_software engineer_2909346.png" ) ;
145
+ var logoObj = new SvgQRCode . SvgLogo ( iconRasterized : logoBitmap , 15 ) ;
146
+ logoObj . GetMediaType ( ) . ShouldBe < SvgQRCode . SvgLogo . MediaType > ( SvgQRCode . SvgLogo . MediaType . PNG ) ;
147
+
148
+ var svg = new SvgQRCode ( data ) . GetGraphic ( 10 , Color . Black , Color . White , drawQuietZones : false , logo : logoObj ) ;
149
+
150
+ var result = HelperFunctions . StringToHash ( svg ) ;
151
+ result . ShouldBe ( "8b4d114136c7fd26e0b34e5a15daac3b" ) ;
152
+ }
125
153
#endif
126
154
127
155
[ Fact ]
@@ -133,7 +161,7 @@ public void can_render_svg_qrcode_with_png_logo_bytearray()
133
161
var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
134
162
135
163
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
136
- var logoBitmap = System . IO . File . ReadAllBytes ( GetAssemblyPath ( ) + "\\ assets\\ noun_software engineer_2909346.png" ) ;
164
+ var logoBitmap = System . IO . File . ReadAllBytes ( HelperFunctions . GetAssemblyPath ( ) + "\\ assets\\ noun_software engineer_2909346.png" ) ;
137
165
var logoObj = new SvgQRCode . SvgLogo ( iconRasterized : logoBitmap , 15 ) ;
138
166
logoObj . GetMediaType ( ) . ShouldBe < SvgQRCode . SvgLogo . MediaType > ( SvgQRCode . SvgLogo . MediaType . PNG ) ;
139
167
@@ -152,7 +180,7 @@ public void can_render_svg_qrcode_with_svg_logo_embedded()
152
180
var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
153
181
154
182
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909361
155
- var logoSvg = File . ReadAllText ( GetAssemblyPath ( ) + "\\ assets\\ noun_Scientist_2909361.svg" ) ;
183
+ var logoSvg = File . ReadAllText ( HelperFunctions . GetAssemblyPath ( ) + "\\ assets\\ noun_Scientist_2909361.svg" ) ;
156
184
var logoObj = new SvgQRCode . SvgLogo ( logoSvg , 20 ) ;
157
185
logoObj . GetMediaType ( ) . ShouldBe < SvgQRCode . SvgLogo . MediaType > ( SvgQRCode . SvgLogo . MediaType . SVG ) ;
158
186
@@ -171,7 +199,7 @@ public void can_render_svg_qrcode_with_svg_logo_image_tag()
171
199
var data = gen . CreateQrCode ( "This is a quick test! 123#?" , QRCodeGenerator . ECCLevel . H ) ;
172
200
173
201
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909361
174
- var logoSvg = File . ReadAllText ( GetAssemblyPath ( ) + "\\ assets\\ noun_Scientist_2909361.svg" ) ;
202
+ var logoSvg = File . ReadAllText ( HelperFunctions . GetAssemblyPath ( ) + "\\ assets\\ noun_Scientist_2909361.svg" ) ;
175
203
var logoObj = new SvgQRCode . SvgLogo ( logoSvg , 20 , iconEmbedded : false ) ;
176
204
177
205
var svg = new SvgQRCode ( data ) . GetGraphic ( 10 , Color . DarkGray , Color . White , logo : logoObj ) ;
0 commit comments