forked from Blazor-Diagrams/Blazor.Diagrams
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fd2736
commit 2b804ae
Showing
2 changed files
with
66 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Blazor.Diagrams.Core.Geometry; | ||
using Blazor.Diagrams.Core.Models; | ||
using Xunit; | ||
|
||
namespace Blazor.Diagrams.Core.Tests.Models | ||
{ | ||
public class NodeModelTest | ||
{ | ||
[Theory] | ||
[InlineData(PortAlignment.Top)] | ||
[InlineData(PortAlignment.TopLeft)] | ||
[InlineData(PortAlignment.TopRight)] | ||
[InlineData(PortAlignment.Bottom)] | ||
[InlineData(PortAlignment.BottomLeft)] | ||
[InlineData(PortAlignment.BottomRight)] | ||
[InlineData(PortAlignment.Left)] | ||
[InlineData(PortAlignment.Right)] | ||
public void UpdatePortOnSetPosition(PortAlignment alignment) | ||
{ | ||
//Arrange | ||
var diagram = new TestDiagram(); | ||
diagram.SetContainer(new Rectangle(0, 0, 1000, 400)); | ||
var node = new NodeModel(position: new Point(100, 100)); | ||
node.Size = new Size(100, 100); | ||
|
||
var port = node.AddPort(alignment); | ||
|
||
var newX = 200; | ||
var newY = 300; | ||
|
||
//Act | ||
node.SetPosition(newX, newY); | ||
|
||
//Assert | ||
Assert.Equal(200, port.Position.X); | ||
Assert.Equal(300, port.Position.Y); | ||
} | ||
|
||
[Theory] | ||
[InlineData(PortAlignment.Top, 300, 100)] | ||
[InlineData(PortAlignment.TopLeft, 100, 100)] | ||
[InlineData(PortAlignment.TopRight, 500, 100)] | ||
[InlineData(PortAlignment.Bottom, 300, 700)] | ||
[InlineData(PortAlignment.BottomLeft, 100, 700)] | ||
[InlineData(PortAlignment.BottomRight, 500, 700)] | ||
[InlineData(PortAlignment.Left, 100, 400)] | ||
[InlineData(PortAlignment.Right, 500, 400)] | ||
public void UpdatePortOnSetSize(PortAlignment alignment, double expectedX, double expectedY) | ||
{ | ||
// Arrange | ||
var oldWidth = 100.0; | ||
var oldHeight = 100.0; | ||
var newWidth = 500.0; | ||
var newHeight = 700.0; | ||
var node = new NodeModel(new Point(100, 100)) { Size = new Size(oldWidth, oldHeight) }; | ||
var port = node.AddPort(alignment); | ||
|
||
// Act | ||
node.SetSize(newWidth, newHeight); | ||
|
||
// Assert | ||
Assert.Equal(expectedX, port.Position.X); | ||
Assert.Equal(expectedY, port.Position.Y); | ||
} | ||
} | ||
} |
85 changes: 0 additions & 85 deletions
85
tests/Blazor.Diagrams.Core.Tests/Positions/Ports/PortTests.cs
This file was deleted.
Oops, something went wrong.