Skip to content

Commit ea42bb0

Browse files
committed
Fixed test case dependencies
1 parent 299f023 commit ea42bb0

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

QRCoderTests/CategoryDiscoverer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
#if !NET35
4+
#if !NET35 && !NET452
55
using Xunit.Abstractions;
66
#endif
77
using Xunit.Sdk;
88

99
namespace QRCoderTests.XUnitExtenstions
1010
{
11-
#if NET35
11+
#if NET35 || NET452
1212
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
1313
public class CategoryAttribute : Attribute
1414
{

QRCoderTests/QRCodeRendererTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private string GetAssemblyPath()
4444
#if NET5_0
4545
System.Reflection.Assembly.GetExecutingAssembly().Location;
4646
#else
47-
System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Replace("file:\\", "");
47+
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "");
4848
#endif
4949
}
5050

QRCoderTests/QRCoderTests.csproj

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,27 @@
88
<IsTestProject>true</IsTestProject>
99
</PropertyGroup>
1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
12-
</ItemGroup>
13-
<ItemGroup Condition=" '$(TargetFramework)' != 'net35' ">
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
12+
</ItemGroup>
13+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net5.0-windows' ">
1414
<PackageReference Include="xunit" Version="2.4.1" />
15-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
16-
<PackageReference Include="shouldly" Version="3.0.2" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
16+
<PackageReference Include="shouldly" Version="4.0.3" />
17+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
18+
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
1719
</ItemGroup>
18-
<ItemGroup Condition=" '$(TargetFramework)' == 'net35' ">
20+
<ItemGroup Condition=" '$(TargetFramework)' == 'net35' or '$(TargetFramework)' == 'net452' ">
1921
<PackageReference Include="xunit" Version="1.9.2" />
2022
<PackageReference Include="xunit.runner.visualstudio" Version="2.0.1" />
2123
<PackageReference Include="shouldly" Version="2.8.3" />
2224
</ItemGroup>
25+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
26+
<PackageReference Include="xunit" Version="2.2.0" />
27+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
28+
<PackageReference Include="shouldly" Version="2.8.3" />
29+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
30+
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
31+
</ItemGroup>
2332
<ItemGroup>
2433
<ProjectReference Include="..\QRCoder\QRCoder.csproj" />
2534
</ItemGroup>

QRCoderTests/SvgQRCodeRendererTests.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@ namespace QRCoderTests
1515
public class SvgQRCodeRendererTests
1616
{
1717

18-
1918
#if !NETCOREAPP1_1 && !NETCOREAPP2_0
2019

20+
private string GetAssemblyPath()
21+
{
22+
return
23+
#if NET5_0
24+
System.Reflection.Assembly.GetExecutingAssembly().Location;
25+
#else
26+
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "");
27+
#endif
28+
}
29+
2130
[Fact]
2231
[Category("QRRenderer/SvgQRCode")]
2332
public void can_render_svg_qrcode()
@@ -59,7 +68,7 @@ public void can_render_svg_qrcode_with_png_logo()
5968
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
6069

6170
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346
62-
var logoBitmap = (Bitmap)Bitmap.FromFile(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "") + "\\assets\\noun_software engineer_2909346.png");
71+
var logoBitmap = (Bitmap)Bitmap.FromFile(GetAssemblyPath() + "\\assets\\noun_software engineer_2909346.png");
6372
var logoObj = new SvgQRCode.SvgLogo(logoBitmap, 15);
6473

6574
var svg = new SvgQRCode(data).GetGraphic(10, Color.DarkGray, Color.White, logo: logoObj);
@@ -80,7 +89,7 @@ public void can_render_svg_qrcode_with_svg_logo()
8089
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
8190

8291
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909361
83-
var logoSvg = File.ReadAllText(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", "") + "\\assets\\noun_Scientist_2909361.svg");
92+
var logoSvg = File.ReadAllText(GetAssemblyPath() + "\\assets\\noun_Scientist_2909361.svg");
8493
var logoObj = new SvgQRCode.SvgLogo(logoSvg, 30);
8594

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

0 commit comments

Comments
 (0)