-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from DomCR/Tolerance-text-format-fix
Tolerance text format fix
- Loading branch information
Showing
10 changed files
with
239 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using ACadSharp.IO; | ||
using System.IO; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace ACadSharp.Tests.IO.DXF | ||
{ | ||
public class DxfWriterSingleObjectTests : WriterSingleObjectTests | ||
{ | ||
public DxfWriterSingleObjectTests(ITestOutputHelper output) : base(output) { } | ||
|
||
[Theory()] | ||
[MemberData(nameof(Data))] | ||
public void WriteCasesAC1018(SingleCaseGenerator data) | ||
{ | ||
this.writeDxfFile(data, ACadVersion.AC1018); | ||
} | ||
|
||
[Theory()] | ||
[MemberData(nameof(Data))] | ||
public void WriteCasesAC1021(SingleCaseGenerator data) | ||
{ | ||
this.writeDxfFile(data, ACadVersion.AC1021); | ||
} | ||
|
||
[Theory()] | ||
[MemberData(nameof(Data))] | ||
public void WriteCasesAC1024(SingleCaseGenerator data) | ||
{ | ||
this.writeDxfFile(data, ACadVersion.AC1024); | ||
} | ||
|
||
[Theory()] | ||
[MemberData(nameof(Data))] | ||
public void WriteCasesAC1027(SingleCaseGenerator data) | ||
{ | ||
this.writeDxfFile(data, ACadVersion.AC1027); | ||
} | ||
|
||
[Theory()] | ||
[MemberData(nameof(Data))] | ||
public void WriteCasesAC1032(SingleCaseGenerator data) | ||
{ | ||
this.writeDxfFile(data, ACadVersion.AC1032); | ||
} | ||
|
||
private void writeDxfFile(SingleCaseGenerator data, ACadVersion version) | ||
{ | ||
if (!TestVariables.RunDwgWriterSingleCases) | ||
return; | ||
|
||
string path = this.getPath(data.Name, "dxf", version); | ||
|
||
data.Document.Header.Version = version; | ||
DxfWriter.Write(path, data.Document, false, this.onNotification); | ||
|
||
this.checkDxfDocumentInAutocad(path); | ||
} | ||
|
||
private string getPath(string name, string ext, ACadVersion version) | ||
{ | ||
return Path.Combine(_singleCasesOutFolder, $"{name}_{version}.{ext}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
using ACadSharp.Entities; | ||
using ACadSharp.Tables; | ||
using CSMath; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace ACadSharp.Tests.IO | ||
{ | ||
public abstract class WriterSingleObjectTests : IOTestsBase | ||
{ | ||
public class SingleCaseGenerator : IXunitSerializable | ||
{ | ||
public string Name { get; private set; } | ||
|
||
public CadDocument Document { get; private set; } = new CadDocument(); | ||
|
||
public SingleCaseGenerator() { } | ||
|
||
public SingleCaseGenerator(string name) | ||
{ | ||
this.Name = name; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return this.Name; | ||
} | ||
|
||
public void Empty() { } | ||
|
||
public void DefaultLayer() | ||
{ | ||
this.Document.Layers.Add(new Layer("default_layer")); | ||
} | ||
|
||
public void EntityColorByLayer() | ||
{ | ||
Layer layer = new Layer("Test"); | ||
layer.Color = new Color(25); | ||
this.Document.Layers.Add(layer); | ||
|
||
Circle c = new Circle(); | ||
c.Center = new XYZ(0, 0, 0); | ||
c.Radius = 10; | ||
c.Layer = layer; | ||
c.Color = Color.ByLayer; | ||
|
||
this.Document.Entities.Add(c); | ||
} | ||
|
||
public void EntityColorTrueColor() | ||
{ | ||
Circle c = new Circle(); | ||
c.Center = new XYZ(0, 0, 0); | ||
c.Radius = 10; | ||
c.Color = Color.FromTrueColor(1151726); | ||
|
||
this.Document.Entities.Add(c); | ||
} | ||
|
||
|
||
public void SingleLine() | ||
{ | ||
Line line = new Line(XYZ.Zero, new XYZ(100, 100, 0)); | ||
|
||
this.Document.Entities.Add(line); | ||
} | ||
|
||
public void SingleMText() | ||
{ | ||
MText mtext = new MText(); | ||
|
||
mtext.Value = "HELLO I'm an MTEXT"; | ||
|
||
this.Document.Entities.Add(mtext); | ||
} | ||
|
||
public void SingleMTextSpecialCharacter() | ||
{ | ||
MText mtext = new MText(); | ||
|
||
mtext.Value = "∅45,6"; | ||
|
||
this.Document.Entities.Add(mtext); | ||
} | ||
|
||
public void SingleMTextMultiline() | ||
{ | ||
MText mtext = new MText(); | ||
|
||
mtext.Value = "HELLO I'm an MTEXT\n and I have multiple lines"; | ||
|
||
this.Document.Entities.Add(mtext); | ||
} | ||
|
||
public void SinglePoint() | ||
{ | ||
this.Document.Entities.Add(new Point(XYZ.Zero)); | ||
} | ||
|
||
public void Deserialize(IXunitSerializationInfo info) | ||
{ | ||
this.Name = info.GetValue<string>(nameof(this.Name)); | ||
this.GetType().GetMethod(this.Name).Invoke(this, null); | ||
} | ||
|
||
public void Serialize(IXunitSerializationInfo info) | ||
{ | ||
info.AddValue(nameof(this.Name), this.Name); | ||
} | ||
} | ||
|
||
public static readonly TheoryData<SingleCaseGenerator> Data; | ||
|
||
public WriterSingleObjectTests(ITestOutputHelper output) : base(output) { } | ||
|
||
static WriterSingleObjectTests() | ||
{ | ||
Data = new(); | ||
if (!TestVariables.RunDwgWriterSingleCases) | ||
{ | ||
Data.Add(new(nameof(SingleCaseGenerator.Empty))); | ||
return; | ||
} | ||
|
||
Data.Add(new(nameof(SingleCaseGenerator.Empty))); | ||
Data.Add(new(nameof(SingleCaseGenerator.SingleLine))); | ||
Data.Add(new(nameof(SingleCaseGenerator.EntityColorByLayer))); | ||
Data.Add(new(nameof(SingleCaseGenerator.EntityColorTrueColor))); | ||
Data.Add(new(nameof(SingleCaseGenerator.DefaultLayer))); | ||
Data.Add(new(nameof(SingleCaseGenerator.SingleMText))); | ||
Data.Add(new(nameof(SingleCaseGenerator.SingleMTextSpecialCharacter))); | ||
Data.Add(new(nameof(SingleCaseGenerator.SingleMTextMultiline))); | ||
Data.Add(new(nameof(SingleCaseGenerator.SinglePoint))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.