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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
//using System.Collections.Generic;
//using System.Globalization;
//using Microsoft.Xna.Framework;
//using Xunit;
//namespace MonoGame.Extended.Tests.Primitives
//{
//
// public class Ray2Tests
// {
// public IEnumerable<TestCaseData> ConstructorTestCases
// {
// get
// {
// yield return
// new TestCaseData(new Point2(), new Vector2()).SetName(
// "The degenerate ray has the expected position and direction.");
// yield return
// new TestCaseData(new Point2(5, 5), new Vector2(15, 15)).SetName(
// "A non-degenerate ray has the expected position and direction.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(ConstructorTestCases))]
// public void Constructor(Point2 position, Vector2 direction)
// {
// var ray = new Ray2(position, direction);
// Assert.Equal(position, ray.Position);
// Assert.Equal(direction, ray.Direction);
// }
// public IEnumerable<TestCaseData> PositionDirectionTestCases
// {
// get
// {
// yield return
// new TestCaseData(new Ray2(), new Point2(), new Vector2()).SetName(
// "The degenerate ray has the expected position and direction.");
// yield return
// new TestCaseData(new Ray2(new Point2(5, 5), new Vector2(15, 15)), new Point2(5, 5),
// new Vector2(15, 15)).SetName
// (
// "A non-degenerate ray has the expected position and direction.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(PositionDirectionTestCases))]
// public void PositionDirection(Ray2 ray, Point2 expectedPosition, Vector2 expecetedDirection)
// {
// Assert.Equal(expectedPosition, ray.Position);
// Assert.Equal(expecetedDirection, ray.Direction);
// ray.Position.X = 10;
// ray.Position.Y = 10;
// Assert.Equal(new Point2(10, 10), ray.Position);
// ray.Direction.X = -10.123f;
// ray.Direction.Y = 10.123f;
// Assert.Equal(new Vector2(-10.123f, 10.123f), ray.Direction);
// }
// public IEnumerable<TestCaseData> IntersectsBoundingRectangleTestCases
// {
// get
// {
// yield return
// new TestCaseData(new Ray2(), new BoundingRectangle(), true, Point2.Zero, Point2.Zero).SetName(
// "The degenerate ray intersects the empty bounding box.");
// yield return
// new TestCaseData(new Ray2(new Point2(-75, -75), new Vector2(75, -75)),
// new BoundingRectangle(new Point2(), new Size2(50, 50)), false, Point2.NaN, Point2.NaN).SetName(
// "A non-degenerate ray that does not cross a non-empty bounding box does not intersect the bounding box.");
// yield return
// new TestCaseData(new Ray2(new Point2(0, 0), new Vector2(25, 0)), new BoundingRectangle(new Point2(), new Size2(50, 50)),
// true, new Point2(0, 0), new Point2(50, 0)).SetName(
// "A non-degenerate ray starting from inside a non-empty bounding box intersects the bounding box.");
// yield return
// new TestCaseData(new Ray2(new Point2(-100, 0), new Vector2(100, 0)),
// new BoundingRectangle(new Point2(), new Size2(50, 50)),
// true, new Point2(-50, 0), new Point2(50, 0)).SetName(
// "A non-degenerate ray crossing a non-empty bounding box intersects the bounding box.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(IntersectsBoundingRectangleTestCases))]
// public void IntersectsBoundingRectangle(Ray2 ray, BoundingRectangle boundingRectangle, bool expectedResult,
// Point2 firstExpectedIntersectionPoint, Point2 secondExpectedIntersectionPoint)
// {
// float rayNearDistance, rayFarDistance;
// var actualResult = ray.Intersects(boundingRectangle, out rayNearDistance, out rayFarDistance);
// Assert.Equal(expectedResult, actualResult);
// if (actualResult)
// {
// var firstActualIntersectionPoint = ray.Position + ray.Direction * rayNearDistance;
// Assert.Equal(firstExpectedIntersectionPoint, firstActualIntersectionPoint);
// var secondActualIntersectionPoint = ray.Position + ray.Direction * rayFarDistance;
// Assert.Equal(secondExpectedIntersectionPoint, secondActualIntersectionPoint);
// }
// else
// {
// Assert.IsTrue(float.IsNaN(rayNearDistance));
// Assert.IsTrue(float.IsNaN(rayFarDistance));
// }
// }
// public IEnumerable<TestCaseData> EqualityTestCases
// {
// get
// {
// yield return
// new TestCaseData(new Ray2(), new Ray2(), true).SetName("Two degenerate rays are equal.");
// yield return
// new TestCaseData(new Ray2(new Point2(float.MinValue, float.MaxValue),
// new Vector2(float.MaxValue, float.MinValue)), new Ray2(new Point2(float.MaxValue, float.MinValue),
// new Vector2(float.MaxValue, float.MinValue)), false).SetName(
// "Two different non-degenerate rays are not equal.");
// yield return
// new TestCaseData(
// new Ray2(new Point2(float.MinValue, float.MaxValue),
// new Vector2(float.MinValue, float.MaxValue)), new Ray2(new Point2(float.MinValue, float.MaxValue),
// new Vector2(float.MinValue, float.MaxValue)), true)
// .SetName(
// "Two identical non-degenerate rays are equal.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(EqualityTestCases))]
// public void Equality(Ray2 ray1, Ray2 ray2, bool expectedToBeEqual)
// {
// Assert.IsTrue(Equals(ray1, ray2) == expectedToBeEqual);
// Assert.IsTrue(ray1 == ray2 == expectedToBeEqual);
// Assert.IsFalse(ray1 == ray2 != expectedToBeEqual);
// Assert.IsTrue(ray1.Equals(ray2) == expectedToBeEqual);
// if (expectedToBeEqual)
// Assert.Equal(ray1.GetHashCode(), ray2.GetHashCode());
// }
// public IEnumerable<TestCaseData> InequalityTestCases
// {
// get
// {
// yield return
// new TestCaseData(new Ray2(), null, false).SetName("A ray is not equal to a null object.");
// yield return
// new TestCaseData(new Ray2(), new object(), false).SetName(
// "A ray is not equal to an instantiated object.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(InequalityTestCases))]
// public void Inequality(Ray2 ray, object obj, bool expectedToBeEqual)
// {
// Assert.IsTrue(ray.Equals(obj) == expectedToBeEqual);
// }
// public IEnumerable<TestCaseData> HashCodeTestCases
// {
// get
// {
// yield return
// new TestCaseData(new Ray2(), new Ray2(), true).SetName(
// "Two degenerate rays have the same hash code.");
// yield return
// new TestCaseData(new Ray2(new Point2(50, 50), new Vector2(50, 50)),
// new Ray2(new Point2(50, 50), new Vector2(50, 50)), true).SetName(
// "Two indentical non-zero points have the same hash code.");
// yield return
// new TestCaseData(new Ray2(new Point2(0, 0), new Vector2(50, 50)),
// new Ray2(new Point2(50, 50), new Vector2(50, 50)), false).SetName(
// "Two different non-zero points do not have the same hash code.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(HashCodeTestCases))]
// public void HashCode(Ray2 ray1, Ray2 ray2, bool expectedThatHashCodesAreEqual)
// {
// var hashCode1 = ray1.GetHashCode();
// var hashCode2 = ray2.GetHashCode();
// if (expectedThatHashCodesAreEqual)
// Assert.Equal(hashCode1, hashCode2);
// else
// Assert.AreNotEqual(hashCode1, hashCode2);
// }
// public IEnumerable<TestCaseData> StringCases
// {
// get
// {
// yield return
// new TestCaseData(new Ray2(),
// string.Format(CultureInfo.CurrentCulture, "Position: {0}, Direction: {1}", new Point2(),
// new Vector2())).SetName(
// "The degenerate ray has the expected string representation using the current culture.");
// yield return new TestCaseData(new Ray2(new Point2(5.1f, -5.123f), new Vector2(0, 1)),
// string.Format(CultureInfo.CurrentCulture, "Position: {0}, Direction: {1}", new Point2(5.1f, -5.123f),
// new Vector2(0, 1))).SetName(
// "A non-degenerate ray has the expected string representation using the current culture.");
// }
// }
// [Fact]
// [TestCaseSource(nameof(StringCases))]
// public void String(Ray2 ray, string expectedString)
// {
// var actualString = ray.ToString();
// Assert.Equal(expectedString, actualString);
// }
// }
//}
|