Skip to content

Commit 6cefe92

Browse files
committed
Re-used existing helper function in Svg tests
1 parent 2f29042 commit 6cefe92

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

QRCoderTests/SvgQRCodeRendererTests.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ namespace QRCoderTests
1515
public class SvgQRCodeRendererTests
1616
{
1717

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-
2818
[Fact]
2919
[Category("QRRenderer/SvgQRCode")]
3020
public void can_render_svg_qrcode_simple()
@@ -113,7 +103,7 @@ public void can_render_svg_qrcode_with_png_logo_bitmap()
113103
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
114104

115105
//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");
117107
var logoObj = new SvgQRCode.SvgLogo(iconRasterized: logoBitmap, 15);
118108
logoObj.GetMediaType().ShouldBe<SvgQRCode.SvgLogo.MediaType>(SvgQRCode.SvgLogo.MediaType.PNG);
119109

@@ -133,7 +123,7 @@ public void can_render_svg_qrcode_with_png_logo_bytearray()
133123
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
134124

135125
//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");
126+
var logoBitmap = System.IO.File.ReadAllBytes(HelperFunctions.GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png");
137127
var logoObj = new SvgQRCode.SvgLogo(iconRasterized: logoBitmap, 15);
138128
logoObj.GetMediaType().ShouldBe<SvgQRCode.SvgLogo.MediaType>(SvgQRCode.SvgLogo.MediaType.PNG);
139129

@@ -152,7 +142,7 @@ public void can_render_svg_qrcode_with_svg_logo_embedded()
152142
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
153143

154144
//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");
145+
var logoSvg = File.ReadAllText(HelperFunctions.GetAssemblyPath() + "\\assets\\noun_Scientist_2909361.svg");
156146
var logoObj = new SvgQRCode.SvgLogo(logoSvg, 20);
157147
logoObj.GetMediaType().ShouldBe<SvgQRCode.SvgLogo.MediaType>(SvgQRCode.SvgLogo.MediaType.SVG);
158148

@@ -171,7 +161,7 @@ public void can_render_svg_qrcode_with_svg_logo_image_tag()
171161
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
172162

173163
//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");
164+
var logoSvg = File.ReadAllText(HelperFunctions.GetAssemblyPath() + "\\assets\\noun_Scientist_2909361.svg");
175165
var logoObj = new SvgQRCode.SvgLogo(logoSvg, 20, iconEmbedded: false);
176166

177167
var svg = new SvgQRCode(data).GetGraphic(10, Color.DarkGray, Color.White, logo: logoObj);

0 commit comments

Comments
 (0)