Skip to content

Commit

Permalink
Re-used existing helper function in Svg tests
Browse files Browse the repository at this point in the history
  • Loading branch information
codebude committed Apr 24, 2024
1 parent 2f29042 commit 6cefe92
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions QRCoderTests/SvgQRCodeRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ namespace QRCoderTests
public class SvgQRCodeRendererTests
{

private string GetAssemblyPath()
{
return
#if NET5_0
AppDomain.CurrentDomain.BaseDirectory;
#else
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "");
#endif
}

[Fact]
[Category("QRRenderer/SvgQRCode")]
public void can_render_svg_qrcode_simple()
Expand Down Expand Up @@ -113,7 +103,7 @@ public void can_render_svg_qrcode_with_png_logo_bitmap()
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);

//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
var logoBitmap = (Bitmap)Image.FromFile(GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png");
var logoBitmap = (Bitmap)Image.FromFile(HelperFunctions.GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png");
var logoObj = new SvgQRCode.SvgLogo(iconRasterized: logoBitmap, 15);
logoObj.GetMediaType().ShouldBe<SvgQRCode.SvgLogo.MediaType>(SvgQRCode.SvgLogo.MediaType.PNG);

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

//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
var logoBitmap = System.IO.File.ReadAllBytes(GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png");
var logoBitmap = System.IO.File.ReadAllBytes(HelperFunctions.GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png");
var logoObj = new SvgQRCode.SvgLogo(iconRasterized: logoBitmap, 15);
logoObj.GetMediaType().ShouldBe<SvgQRCode.SvgLogo.MediaType>(SvgQRCode.SvgLogo.MediaType.PNG);

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

//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909361
var logoSvg = File.ReadAllText(GetAssemblyPath() + "\\assets\\noun_Scientist_2909361.svg");
var logoSvg = File.ReadAllText(HelperFunctions.GetAssemblyPath() + "\\assets\\noun_Scientist_2909361.svg");
var logoObj = new SvgQRCode.SvgLogo(logoSvg, 20);
logoObj.GetMediaType().ShouldBe<SvgQRCode.SvgLogo.MediaType>(SvgQRCode.SvgLogo.MediaType.SVG);

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

//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909361
var logoSvg = File.ReadAllText(GetAssemblyPath() + "\\assets\\noun_Scientist_2909361.svg");
var logoSvg = File.ReadAllText(HelperFunctions.GetAssemblyPath() + "\\assets\\noun_Scientist_2909361.svg");
var logoObj = new SvgQRCode.SvgLogo(logoSvg, 20, iconEmbedded: false);

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

0 comments on commit 6cefe92

Please sign in to comment.