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
66 changes: 66 additions & 0 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Windows CI

# Builds the kernel and CADability.Forms and runs both test projects on Windows. There CADability.Tests
# targets net8.0-windows and also runs the tests that need GDI+, WinForms or OpenGL (e.g. the
# comparison of the GDI+ conversions in CADability.Forms with the kernel, and the rendering of
# geometry compared against reference bitmaps), which the Linux CI compiles out (issue #412).

on:
pull_request:
push:
branches:
- master
workflow_dispatch:

permissions:
contents: read

concurrency:
group: windows-ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-test:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# ACadSharp is built from source (external/ACadSharp submodule, which
# itself pulls in CSUtilities as a submodule)
submodules: recursive

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
# ACadSharp's TargetFrameworks include net10.0, so restore needs the .NET 10 SDK.
# The test projects target net8.0 (net8.0-windows), so its runtimes are installed as well.
dotnet-version: |
8.0.x
10.0.x

- name: Build the kernel
run: dotnet build CADability/CADability.csproj -c Release

- name: Build CADability.Forms
run: dotnet build CADability.Forms/CADability.Forms.csproj -c Release

- name: Run CADability.Tests
run: >
dotnet test tests/CADability.Tests/CADability.Tests.csproj -c Release
--logger "trx;LogFileName=CADability.Tests.trx"
--results-directory TestResults

- name: Run CADability.ImportTests
if: success() || failure()
run: >
dotnet test tests/CADability.ImportTests/CADability.ImportTests.csproj -c Release
--logger "trx;LogFileName=CADability.ImportTests.trx"
--results-directory TestResults

- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: test-results-windows
path: TestResults/*.trx
22 changes: 14 additions & 8 deletions tests/CADability.ImportTests/DxfDimensionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,12 @@ public void export_dimension_round_trips_as_a_dxf_dimension()
// Header, the red layer "Dimensions" and a dimension style "LOGICAL" with values that are
// nothing like CADability's defaults, so a translation is visible in the assertions:
// DIMSCALE 2, DIMASZ 1.5, DIMEXO 0.5, DIMEXE 1.25, DIMTXT 3.5, DIMDEC 3.
/// <summary>
/// The fixtures are verbatim strings, so they have the line endings of the checkout: CRLF on Windows with
/// text=auto. A test that edits a fixture with Replace("...\n...") normalizes it to LF first.
/// </summary>
private static string Lf(string fixture) => fixture.Replace("\r\n", "\n");

private const string StyledPrologue = @" 0
SECTION
2
Expand Down Expand Up @@ -993,8 +999,8 @@ public void import_dxf_dimension_translates_the_dimension_style()
[TestMethod]
public void import_dxf_dimension_uses_the_standard_style_of_the_file()
{
string standard = LinearDimension.Replace(" 3\nLOGICAL\n", "");
Assert.AreNotEqual(LinearDimension, standard, "the style reference should be removed");
string standard = Lf(LinearDimension).Replace(" 3\nLOGICAL\n", "");
Assert.AreNotEqual(Lf(LinearDimension), standard, "the style reference should be removed");
Project project = ImportProjectAsDimensions(StyledPrologue + standard + Epilogue);
Dimension dim = SingleDimensionObject(project.GetActiveModel());

Expand Down Expand Up @@ -1211,11 +1217,11 @@ public void import_dxf_degenerate_dimension_keeps_its_block()
{
// drop the rotated subclass to make it an aligned dimension, and put the second
// measured point straight above the first, along the normal
string degenerate = LinearDimension
string degenerate = Lf(LinearDimension)
.Replace("100\nAcDbRotatedDimension\n 50\n0.0\n", "")
.Replace(" 14\n100.0", " 14\n0.0")
.Replace(" 34\n0.0", " 34\n100.0");
Assert.AreNotEqual(LinearDimension, degenerate, "the fixture should have been changed");
Assert.AreNotEqual(Lf(LinearDimension), degenerate, "the fixture should have been changed");
Model model = ImportAsDimensions(StyledPrologue + degenerate + Epilogue);

Assert.AreEqual(1, model.Count, "it must not get lost");
Expand All @@ -1230,9 +1236,9 @@ public void import_dxf_degenerate_dimension_keeps_its_block()
[TestMethod]
public void import_dxf_dimension_text_override_keeps_the_measurement()
{
string withText = LinearDimension.Replace("100\nAcDbAlignedDimension",
string withText = Lf(LinearDimension).Replace("100\nAcDbAlignedDimension",
" 1\nca. <> mm\n100\nAcDbAlignedDimension");
Assert.AreNotEqual(LinearDimension, withText, "the text override should be inserted");
Assert.AreNotEqual(Lf(LinearDimension), withText, "the text override should be inserted");
Dimension dim = SingleDimensionObject(ImportAsDimensions(StyledPrologue + withText + Epilogue));

dim.GetBoundingCube();
Expand Down Expand Up @@ -1389,8 +1395,8 @@ public void import_dxf_arc_length_dimension_does_not_share_the_style_of_a_linear
public void import_dxf_dimension_translates_the_angle_format()
{
// DIMAUNIT (group code 275) 1 is degrees, minutes and seconds
string prologue = StyledPrologue.Replace("271\n3\n", "271\n3\n275\n1\n");
Assert.AreNotEqual(StyledPrologue, prologue, "DIMAUNIT should be set");
string prologue = Lf(StyledPrologue).Replace("271\n3\n", "271\n3\n275\n1\n");
Assert.AreNotEqual(Lf(StyledPrologue), prologue, "DIMAUNIT should be set");
Dimension dim = SingleDimensionObject(ImportAsDimensions(prologue + LinearDimension + Epilogue));

Assert.AreEqual(DimensionStyle.EAngleText.DegreeMinuteSecond, dim.DimensionStyle.AngleText);
Expand Down
2 changes: 2 additions & 0 deletions tests/CADability.Tests/RendererRecoveryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Runtime.InteropServices;
using CADability.GeoObject;
using CADability.Substitutes;
// with UseWindowsForms (the Windows build of the tests), System.Windows.Forms has a PaintEventArgs as well
using PaintEventArgs = CADability.Substitutes.PaintEventArgs;

namespace CADability.Tests
{
Expand Down
Loading