Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mme1950 authored Aug 14, 2024
2 parents a8425f0 + 52e26ae commit 7ed035b
Show file tree
Hide file tree
Showing 110 changed files with 1,238 additions and 365 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"netdocgen.runner": {
"version": "0.1.0",
"version": "0.1.1",
"commands": [
"netdocgen"
],
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Coveralls

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
SAMPLES_FOLDER: "../../../../samples"
OUTPUT_SAMPLES_FOLDER: "../../../../samples/out"
OUTPUT_SINGLE_CASES_FOLDER: "../../../../samples/out/single_cases"
LOCAL_ENV: "false"
DELTA: "0.00001"
DECIMAL_PRECISION: "5"
RUN_DWG_WRITER_SINGLE_CASES_TEST: "false"

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test -p:CollectCoverage=true -p:CoverletOutput=TestResults/ -p:CoverletOutputFormat=lcov --no-build --verbosity normal ACadSharp.Tests/
- name: Coveralls action
uses: coverallsapp/github-action@master
with:
github-token: ${{ github.token }}
path-to-lcov: ACadSharp.Tests/TestResults/coverage.info
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "CSUtilities"]
path = CSUtilities
url = https://github.com/DomCR/CSUtilities
[submodule "wiki"]
path = wiki
url = https://github.com/DomCR/ACadSharp.wiki.git
6 changes: 5 additions & 1 deletion ACadSharp.Tests/ACadSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
<PackageReference Include="MSTest.TestAdapter" Version="3.*" />
<PackageReference Include="MSTest.TestFramework" Version="3.*" />
<PackageReference Include="coverlet.collector" Version="6.*">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 6 additions & 0 deletions ACadSharp.Tests/CadDocumentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using ACadSharp.Entities;
using Xunit.Abstractions;
using ACadSharp.Blocks;
using System.Linq;

namespace ACadSharp.Tests
{
Expand Down Expand Up @@ -50,6 +51,11 @@ public void CadDocumentDefaultTest()
this._docIntegrity.AssertDocumentDefaults(doc);
this._docIntegrity.AssertTableHirearchy(doc);
this._docIntegrity.AssertBlockRecords(doc);

Assert.Equal(2, doc.BlockRecords.Count);
Assert.Equal(1, doc.Layers.Count);
Assert.Equal(3, doc.LineTypes.Count);
Assert.Equal(2, doc.Layouts.Count());
}

[Fact]
Expand Down
4 changes: 3 additions & 1 deletion ACadSharp.Tests/Common/DocumentIntegrity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ public void AssertDocumentDefaults(CadDocument doc)
this.entryNotNull(doc.VPorts, "*Active");

//Assert Model layout
var layout = doc.Layouts.FirstOrDefault(l => l.Name == Layout.LayoutModelName);
var layout = doc.Layouts.FirstOrDefault(l => l.Name == Layout.ModelLayoutName);

this.notNull(layout, "Layout Model is null");

Assert.True(layout.AssociatedBlock == doc.ModelSpace);
}

Expand Down
9 changes: 9 additions & 0 deletions ACadSharp.Tests/Entities/EntityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ static EntityTests()
}
}

[Theory]
[MemberData(nameof(EntityTypes))]
public void BoundingBoxTest(Type entityType)
{
Entity entity = EntityFactory.Create(entityType);

entity.GetBoundingBox();
}

[Theory]
[MemberData(nameof(EntityTypes))]
public void Clone(Type entityType)
Expand Down
8 changes: 4 additions & 4 deletions ACadSharp.Tests/IO/CadReaderTestsBase.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using ACadSharp.Entities;
using ACadSharp.Header;
using ACadSharp.Header;
using ACadSharp.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using Xunit.Abstractions;

namespace ACadSharp.Tests.IO
{
public abstract class CadReaderTestsBase<T> : IOTestsBase, IDisposable
where T : CadReaderBase
where T : ICadReader
{
protected readonly Dictionary<string, CadDocument> _documents = new Dictionary<string, CadDocument>(); //TODO: this does not store the document readed

Expand Down Expand Up @@ -38,6 +36,8 @@ public virtual void AssertDocumentDefaults(string test)
{
CadDocument doc = this.getDocument(test);

Assert.NotNull(doc.SummaryInfo);

if (doc.Header.Version < ACadVersion.AC1012)
{
//Older version do not keep the handles for tables and other objects like block_records
Expand Down
2 changes: 1 addition & 1 deletion ACadSharp.Tests/IO/DWG/DwgWriterSingleObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected virtual void writeDwgFile(SingleCaseGenerator data, ACadVersion versio
string path = this.getPath(data.Name, "dwg", version);

data.Document.Header.Version = version;
DwgWriter.Write(path, data.Document, this.onNotification);
DwgWriter.Write(path, data.Document, notification: this.onNotification);
}
}
}
2 changes: 1 addition & 1 deletion ACadSharp.Tests/IO/IOTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void DxfToDxf(string test)
{
CadDocument doc = DxfReader.Read(test);

if(doc.Header.Version < ACadVersion.AC1012)
if (doc.Header.Version < ACadVersion.AC1012)
{
return;
}
Expand Down
1 change: 0 additions & 1 deletion ACadSharp.Tests/IO/LocalSampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void ReadUserDxf(string test)
}
}


[Theory]
[MemberData(nameof(StressFiles))]
public void ReadStressFiles(string test)
Expand Down
56 changes: 51 additions & 5 deletions ACadSharp.Tests/IO/WriterSingleObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,40 @@ public void SingleRasterImage()
this.Document.Entities.Add(raster);
}

public void CreateLayout()
{
//Draw a cross in the model
this.Document.Entities.Add(new Line(XYZ.Zero, new XYZ(100, 100, 0)));
this.Document.Entities.Add(new Line(new XYZ(0, 100, 0), new XYZ(100, 0, 0)));

Layout layout = new Layout("my_layout");

this.Document.Layouts.Add(layout);
}

public void LineTypeWithSegments()
{
LineType lt = new LineType("segmented");
lt.Description = "hello";

LineType.Segment s1 = new LineType.Segment
{
Length = 12,
//Style = this.Document.TextStyles[TextStyle.DefaultName]
};

LineType.Segment s2 = new LineType.Segment
{
Length = -3,
//Style = this.Document.TextStyles[TextStyle.DefaultName]
};

lt.AddSegment(s1);
lt.AddSegment(s2);

this.Document.LineTypes.Add(lt);
}

public void ClosedLwPolyline()
{
List<LwPolyline.Vertex> vertices = new List<LwPolyline.Vertex>() {
Expand Down Expand Up @@ -208,12 +242,21 @@ public void ClosedPolyline2DTest()
new Vertex2D() { Location = new XYZ(4, 4, 0) }
};

var Pline = new Polyline2D();
Pline.Vertices.AddRange(vector2d);
Pline.IsClosed = true;
Pline.Vertices.ElementAt(3).Bulge = 1;
var pline = new Polyline2D();
pline.Vertices.AddRange(vector2d);
pline.IsClosed = true;
pline.Vertices.ElementAt(3).Bulge = 1;

this.Document.Entities.Add(pline);
}

this.Document.Entities.Add(Pline);
public void EntityTransparency()
{
Line line = new Line(XYZ.Zero, new XYZ(100, 100, 0));

line.Transparency = new Transparency(50);

this.Document.Entities.Add(line);
}

public void Deserialize(IXunitSerializationInfo info)
Expand Down Expand Up @@ -257,6 +300,9 @@ static WriterSingleObjectTests()
Data.Add(new(nameof(SingleCaseGenerator.ClosedPolyline2DTest)));
Data.Add(new(nameof(SingleCaseGenerator.SingleRasterImage)));
Data.Add(new(nameof(SingleCaseGenerator.SingleWipeout)));
Data.Add(new(nameof(SingleCaseGenerator.CreateLayout)));
Data.Add(new(nameof(SingleCaseGenerator.EntityTransparency)));
Data.Add(new(nameof(SingleCaseGenerator.LineTypeWithSegments)));
}

protected string getPath(string name, string ext, ACadVersion version)
Expand Down
18 changes: 17 additions & 1 deletion ACadSharp.Tests/Objects/CadDictionaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@ public void AvoidDuplicatedEntries()
cadDictionary.Add(scale);

Scale scale1 = new Scale();
scale1.Name = "scale_test";

Assert.Throws<ArgumentException>(() => cadDictionary.Add(scale1));

scale.Name = "changed_name";
scale1.Name = "changed_name";

Assert.Throws<ArgumentException>(() => cadDictionary.Add(scale1));
}

[Fact]
public void TryAddTest()
{
CadDictionary cadDictionary = new CadDictionary();
Scale scale = new Scale();
scale.Name = "scale_test";

Assert.Throws<ArgumentException>(() => cadDictionary.Add(scale));
Assert.True(cadDictionary.TryAdd(scale));
Assert.False(cadDictionary.TryAdd(scale));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace ACadSharp.Tests.Objects.Collections
{
public class ScaleCollectionTests
{
[Fact(Skip = "test needed for root dictionary")]
[Fact]
public void InitScaleCollection()
{
CadDocument doc = new CadDocument();
Expand Down
67 changes: 67 additions & 0 deletions ACadSharp.Tests/Objects/LayoutTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using ACadSharp.Objects;
using System;
using System.Linq;
using Xunit;

namespace ACadSharp.Tests.Objects
{
public class LayoutTests
{
[Fact]
public void AddLayout()
{
CadDocument document = new CadDocument();

string layoutName = "my_layout";
Layout layout = new Layout(layoutName);

document.Layouts.Add(layout);

Assert.Equal(layoutName, layout.AssociatedBlock.Name);
Assert.Equal(3, document.Layouts.Count());
Assert.True(document.BlockRecords.Contains(layoutName));
}

[Fact]
public void RemoveBlockRecordTest()
{
var document = new CadDocument();

string layoutName = "my_layout";
Layout layout = new Layout(layoutName);

document.Layouts.Add(layout);

document.BlockRecords.Remove(layoutName);

Assert.Equal(2, document.Layouts.Count());
Assert.False(document.Layouts.ContainsKey(layoutName));
Assert.False(document.BlockRecords.Contains(layoutName));
}

[Fact]
public void RemoveTest()
{
var document = new CadDocument();

string layoutName = "my_layout";
Layout layout = new Layout(layoutName);

document.Layouts.Add(layout);

Assert.True(document.Layouts.Remove(layoutName));
Assert.Equal(2, document.Layouts.Count());
Assert.True(document.BlockRecords.Contains(layoutName));
Assert.NotEqual(document.BlockRecords[layoutName], layout.AssociatedBlock);
}

[Fact]
public void CannotRemoveDefaultLayouts()
{
var document = new CadDocument();

Assert.Throws<ArgumentException>(() => document.Layouts.Remove(Layout.ModelLayoutName));
Assert.Throws<ArgumentException>(() => document.Layouts.Remove(Layout.PaperLayoutName));
}
}
}
20 changes: 0 additions & 20 deletions ACadSharp.Tests/Objects/ScaleCollectionTests.cs

This file was deleted.

1 change: 1 addition & 0 deletions ACadSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\build_n_test.yml = .github\workflows\build_n_test.yml
publish.yml = publish.yml
.github\workflows\coveralls.yml = .github\workflows\coveralls.yml
.github\workflows\wiki-gen.yml = .github\workflows\wiki-gen.yml
EndProjectSection
EndProject
Expand Down
2 changes: 1 addition & 1 deletion ACadSharp/ACadSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>2.3.2-beta</Version>
<Version>2.4.0-beta</Version>
</PropertyGroup>

<Import Project="..\CSUtilities\CSMath\CSMath.projitems" Label="Shared" />
Expand Down
Loading

0 comments on commit 7ed035b

Please sign in to comment.