-
-
Notifications
You must be signed in to change notification settings - Fork 120
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 #168 from DomCR/issue-166_seqend-management
Seqend management
- Loading branch information
Showing
12 changed files
with
247 additions
and
32 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,35 @@ | ||
using ACadSharp.Entities; | ||
using CSMath; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace ACadSharp.Tests.Entities | ||
{ | ||
public class PolylineTest | ||
{ | ||
[Fact] | ||
public void ClearVertrticesTest() | ||
{ | ||
CadDocument doc = new CadDocument(); | ||
|
||
Polyline2D polyline = new Polyline2D(); | ||
List<Vertex2D> vertices = new List<Vertex2D> | ||
{ | ||
new Vertex2D(), | ||
new Vertex2D(new XY(1,1)), | ||
new Vertex2D(new XY(2,2)) | ||
}; | ||
polyline.Vertices.AddRange(vertices); | ||
|
||
doc.Entities.Add(polyline); | ||
|
||
polyline.Vertices.Clear(); | ||
|
||
foreach (var item in vertices) | ||
{ | ||
Assert.True(item.Handle == 0); | ||
Assert.False(doc.TryGetCadObject(item.Handle, out Vertex2D _)); | ||
} | ||
} | ||
} | ||
} |
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,91 @@ | ||
using ACadSharp.Entities; | ||
using Xunit; | ||
|
||
namespace ACadSharp.Tests.Entities | ||
{ | ||
public class SeqendTests | ||
{ | ||
[Fact] | ||
public void NullTest() | ||
{ | ||
Polyline2D polyline = new Polyline2D(); | ||
|
||
Assert.Null(polyline.Vertices.Seqend); | ||
} | ||
|
||
[Fact] | ||
public void CreatedTest() | ||
{ | ||
Polyline2D polyline = new Polyline2D(); | ||
polyline.Vertices.Add(new Vertex2D()); | ||
|
||
Assert.NotNull(polyline.Vertices.Seqend); | ||
Assert.True(polyline.Vertices.Seqend.Handle == 0); | ||
Assert.NotEmpty(polyline.Vertices); | ||
} | ||
|
||
[Fact] | ||
public void RemovedTest() | ||
{ | ||
Polyline2D polyline = new Polyline2D(); | ||
polyline.Vertices.Add(new Vertex2D()); | ||
|
||
Assert.NotNull(polyline.Vertices.Seqend); | ||
Assert.True(polyline.Vertices.Seqend.Handle == 0); | ||
Assert.NotEmpty(polyline.Vertices); | ||
|
||
polyline.Vertices.Clear(); // Empty collection | ||
|
||
Assert.Null(polyline.Vertices.Seqend); | ||
} | ||
|
||
[Fact] | ||
public void AddToDocumentTest() | ||
{ | ||
CadDocument doc = new CadDocument(); | ||
|
||
Polyline2D polyline = new Polyline2D(); | ||
polyline.Vertices.Add(new Vertex2D()); | ||
|
||
doc.Entities.Add(polyline); | ||
|
||
Assert.False(polyline.Vertices.Seqend.Handle == 0); | ||
Seqend inner = doc.GetCadObject<Seqend>(polyline.Vertices.Seqend.Handle); | ||
Assert.NotNull(inner); | ||
} | ||
|
||
[Fact] | ||
public void OnSeqendAddedTest() | ||
{ | ||
CadDocument doc = new CadDocument(); | ||
|
||
Polyline2D polyline = new Polyline2D(); | ||
|
||
doc.Entities.Add(polyline); | ||
|
||
polyline.Vertices.Add(new Vertex2D()); | ||
|
||
Assert.False(polyline.Vertices.Seqend.Handle == 0); | ||
Assert.True(doc.TryGetCadObject(polyline.Vertices.Seqend.Handle, out Seqend inner)); | ||
Assert.NotNull(inner); | ||
} | ||
|
||
[Fact] | ||
public void OnSeqendRemovedTest() | ||
{ | ||
CadDocument doc = new CadDocument(); | ||
|
||
Polyline2D polyline = new Polyline2D(); | ||
polyline.Vertices.Add(new Vertex2D()); | ||
Seqend holder = polyline.Vertices.Seqend; | ||
|
||
doc.Entities.Add(polyline); | ||
|
||
polyline.Vertices.Clear(); | ||
|
||
Assert.True(holder.Handle == 0); | ||
Assert.False(doc.TryGetCadObject(holder.Handle, out Seqend inner)); | ||
Assert.Null(inner); | ||
} | ||
} | ||
} |
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 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 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 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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
using ACadSharp.Entities; | ||
using System; | ||
using System.Collections; | ||
|
||
namespace ACadSharp | ||
{ | ||
public interface ISeqendColleciton | ||
public interface ISeqendCollection : IEnumerable | ||
{ | ||
public event EventHandler<CollectionChangedEventArgs> OnSeqendAdded; | ||
|
||
public event EventHandler<CollectionChangedEventArgs> OnSeqendRemoved; | ||
|
||
Seqend Seqend { get; } | ||
} | ||
} |
Oops, something went wrong.