Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions .github/workflows/wf-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ jobs:
run: dotnet restore

- name: Build library
run: dotnet build -c Release --no-restore
run: dotnet build -c Debug --no-restore

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Compiled project
path: ${{ github.workspace }}
retention-days: 1

test:
needs: build
Expand Down Expand Up @@ -67,19 +68,15 @@ jobs:
run: |
$coverage = if ("${{ matrix.dotnet-framework.coverage }}" -eq "true") { "/p:CollectCoverage=true /p:CoverletOutputFormat=opencover" } else { "" }
$noBuild = if ("${{ matrix.dotnet-framework.no-build }}" -eq "true") { "--no-build" } else { "" }
dotnet test -c Release -f ${{ matrix.dotnet-framework.framework }} --nologo $noBuild $coverage
dotnet test -c Debug -f ${{ matrix.dotnet-framework.framework }} --nologo $noBuild $coverage

additional-tests:
needs: build
runs-on: windows-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Compiled project
path: ${{ github.workspace }}
- uses: actions/checkout@v4
name: Checkout Code

- name: Install additional .NET SDKs
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
Expand All @@ -90,14 +87,4 @@ jobs:

- name: Run API approval tests
working-directory: QRCoderApiTests
run: dotnet test -c Release --nologo --no-build

clean:
needs: [build, test, additional-tests]
if: always()
runs-on: windows-latest
steps:
- name: Delete artifacts
uses: GeekyEggo/delete-artifact@v5
with:
name: Compiled project
run: dotnet test -c Release --nologo
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,5 @@ pip-log.txt
QRCoder/PortabilityAnalysis.html

# Unaccepted approval files
QRCoderTests/*.received.*
*.received.txt
9 changes: 7 additions & 2 deletions QRCoderDemo/QRCoderDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;net5.0-windows</TargetFrameworks>
<TargetFrameworks>net462;net5.0-windows</TargetFrameworks>
<UseWindowsForms Condition="'$(TargetFramework)' == 'net5.0-windows'">true</UseWindowsForms>
<OutputType>Exe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Windows.Forms" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\QRCoder\QRCoder.csproj">
<Project>{aa6be23a-7813-4d2a-835e-b673631ae9f1}</Project>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 6 additions & 18 deletions QRCoderTests/ArtQRCodeRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public void can_create_standard_qrcode_graphic()
var gen = new QRCodeGenerator();
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
var bmp = new ArtQRCode(data).GetGraphic(10);

var result = HelperFunctions.BitmapToHash(bmp);
result.ShouldBe("df510ce9feddc0dd8c23c54e700abbf0");
bmp.ShouldMatchApproved();
}

[Fact]
Expand All @@ -32,9 +30,7 @@ public void can_create_standard_qrcode_graphic_with_custom_finder()
g.FillRectangle(Brushes.Red, 0, 0, 70, 70);
}
var bmp = new ArtQRCode(data).GetGraphic(10, Color.Black, Color.White, Color.Transparent, finderPatternImage: finder);

var result = HelperFunctions.BitmapToHash(bmp);
result.ShouldBe("e28a3779b9b975b85984e36f596c9a35");
bmp.ShouldMatchApproved();
}

[Fact]
Expand All @@ -43,9 +39,7 @@ public void can_create_standard_qrcode_graphic_without_quietzone()
var gen = new QRCodeGenerator();
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
var bmp = new ArtQRCode(data).GetGraphic(10, Color.Black, Color.White, Color.Transparent, drawQuietZones: false);

var result = HelperFunctions.BitmapToHash(bmp);
result.ShouldBe("54408da26852d6c67ab7cad2656da7fa");
bmp.ShouldMatchApproved();
}

[Fact]
Expand All @@ -55,10 +49,7 @@ public void can_create_standard_qrcode_graphic_with_background()
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
var bmp = new ArtQRCode(data).GetGraphic(HelperFunctions.GetIconBitmap());
//Used logo is licensed under public domain. Ref.: https://thenounproject.com/Iconathon1/collection/redefining-women/?i=2909346

var result = HelperFunctions.BitmapToHash(bmp);

result.ShouldBe("7f039ccde219ae78e4f768466376a17f");
bmp.ShouldMatchApproved();
}

[Fact]
Expand All @@ -68,9 +59,7 @@ public void should_throw_pixelfactor_oor_exception()
var data = gen.CreateQrCode("This is a quick test! 123#?", QRCodeGenerator.ECCLevel.H);
var aCode = new ArtQRCode(data);

var exception = Record.Exception(() => aCode.GetGraphic(10, Color.Black, Color.White, Color.Transparent, pixelSizeFactor: 2));
Assert.NotNull(exception);
Assert.IsType<System.Exception>(exception);
var exception = Should.Throw<System.Exception>(() => aCode.GetGraphic(10, Color.Black, Color.White, Color.Transparent, pixelSizeFactor: 2));
exception.Message.ShouldBe("The parameter pixelSize must be between 0 and 1. (0-100%)");
}

Expand All @@ -87,8 +76,7 @@ public void can_render_artqrcode_from_helper()
{
//Create QR code
var bmp = ArtQRCodeHelper.GetQRCode("A", 10, Color.Black, Color.White, Color.Transparent, QRCodeGenerator.ECCLevel.L);
var result = HelperFunctions.BitmapToHash(bmp);
result.ShouldBe("a1975852df9b537344468bd44d54abe0");
bmp.ShouldMatchApproved();
}
}
#endif
Loading