| Name | Message | Date |
|---|---|---|
| 📄 AvoidCrossingsShould.cs | 5 days ago | |
| 📄 ConstructShould.cs | 5 days ago | |
| 📄 SettleShould.cs | 5 days ago | |
| 📄 TickShould.cs | 5 days ago |
📄
ui/tests/PhysicsLayoutTests/ConstructShould.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System; using Avalonia; using Cfa.Ui.Graph; using Shouldly; using Xunit; namespace Cfa.Ui.Tests.PhysicsLayoutTests; public sealed class ConstructShould { [Fact] public void RejectMissingOrNonfiniteInitialCoordinates() { // Arrange PhysicsNode[] nodes = [new(-1, 100), new(0, 100)]; Point[][] starts = [ [default], [default, new Point(double.NaN, 0)], ]; foreach (var start in starts) { // Act var construct = () => new PhysicsLayout(nodes, initialPositions: start); // Assert construct.ShouldThrow<ArgumentException>(); } } [Fact] public void NormalizeTheSuppliedOriginToZeroWithoutChangingRelativePositions() { // Arrange Point[] starts = [new(50, 70), new(150, 100)]; // Act var layout = new PhysicsLayout([new(-1, 100), new(0, 100)], initialPositions: starts); // Assert layout.Positions[0].ShouldBe(default(Point)); layout.Positions[1].ShouldBe(new Point(100, 30)); starts[0].ShouldBe(new Point(50, 70)); } [Theory] [InlineData(0)] [InlineData(-1)] [InlineData(double.NaN)] [InlineData(double.PositiveInfinity)] public void RejectInvalidRadii(double radius) { // Arrange PhysicsNode[] nodes = [new(-1, radius)]; // Act var construct = () => new PhysicsLayout(nodes); // Assert construct.ShouldThrow<ArgumentException>(); } [Theory] [InlineData(-1)] [InlineData(1)] [InlineData(5)] public void RejectMissingParentsAndCycles(int parent) { // Arrange PhysicsNode[] nodes = [new(-1, 100), new(parent, 100)]; // Act var construct = () => new PhysicsLayout(nodes); // Assert construct.ShouldThrow<ArgumentException>(); } [Fact] public void RejectInvalidSimulationSettings() { // Arrange PhysicsOptions[] settings = [ new() { MaxIterations = 0 }, new() { Damping = 1 }, new() { Damping = -1 }, new() { MaxSpeed = 0 }, new() { SpringStrength = double.NaN }, new() { Tolerance = 0 }, new() { EdgeCrossingStrength = -1 }, new() { EdgeNodeStrength = double.NaN }, new() { EdgeClearance = 0 }, ]; foreach (var setting in settings) { // Act var construct = () => new PhysicsLayout([], setting); // Assert construct.ShouldThrow<ArgumentOutOfRangeException>(); } } }