summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/Primitives/Point2Tests.cs
blob: ce5f89be306f474a92ab1c4b76599a906281c7f4 (plain)
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
//using System.Collections.Generic;
//using System.Globalization;
//using Microsoft.Xna.Framework;
//using Xunit;

//namespace MonoGame.Extended.Tests.Primitives
//{
//    
//    public class Point2Tests
//    {
//        public IEnumerable<TestCaseData> ConstructorTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(0, 0).SetName(
//                        "The zero point has the expected coordinates.");
//                yield return
//                    new TestCaseData(float.MinValue, float.MaxValue).SetName
//                    (
//                        "A non-zero point has the expected coordinates.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(ConstructorTestCases))]
//        public void Constructor(float x, float y)
//        {
//            var point = new Point2(x, y);
//            Assert.Equal(x, point.X);
//            Assert.Equal(y, point.Y);
//        }

//        public IEnumerable<TestCaseData> CoordinatesTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), 0, 0).SetName(
//                        "The zero point has the expected coordinates.");
//                yield return
//                    new TestCaseData(new Point2(float.MinValue, float.MaxValue), float.MinValue, float.MaxValue).SetName
//                    (
//                        "A non-zero point has the expected coordinates.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(CoordinatesTestCases))]
//        public void Coordinates(Point2 point, float expectedX, float expecetedY)
//        {
//            Assert.Equal(expectedX, point.X);
//            Assert.Equal(expecetedY, point.Y);

//            point.X = 10;
//            Assert.Equal(10, point.X);

//            point.Y = -10.123f;
//            Assert.Equal(-10.123f, point.Y);
//        }

//        public IEnumerable<TestCaseData> VectorAdditionTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Vector2(), new Point2()).SetName(
//                        "The addition of the zero point and the zero vector is the zero point.");
//                yield return
//                    new TestCaseData(new Point2(5, 5), new Vector2(15, 15), new Point2(20, 20)).SetName(
//                        "The addition of a non-zero point and a non-zero vector is the expected point.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(VectorAdditionTestCases))]
//        public void VectorAddition(Point2 point, Vector2 vector, Point2 expectedPoint)
//        {
//            Assert.Equal(expectedPoint, point + vector);
//            Assert.Equal(expectedPoint, Point2.Add(point, vector));
//        }

//        public IEnumerable<TestCaseData> VectorSubtractionTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Vector2(), new Point2()).SetName(
//                        "The vector subtraction of two zero points is the zero vector.");
//                yield return
//                    new TestCaseData(new Point2(5, 5), new Vector2(15, 15), new Point2(-10, -10)).SetName(
//                        "The vector subtraction of two non-zero points is the expected vector.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(VectorSubtractionTestCases))]
//        public void VectorSubtraction(Point2 point, Vector2 vector, Point2 expectedPoint)
//        {
//            Assert.Equal(expectedPoint, point - vector);
//            Assert.Equal(expectedPoint, Point2.Subtract(point, vector));
//        }


//        public IEnumerable<TestCaseData> DisplacementTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Point2(), new Vector2()).SetName(
//                        "The displacement between two zero points is the zero vector.");
//                yield return
//                    new TestCaseData(new Point2(5, 5), new Point2(15, 15), new Vector2(10, 10)).SetName(
//                        "The displacement between two non-zero points is the expected vector.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(DisplacementTestCases))]
//        public void Displacement(Point2 point1, Point2 point2, Vector2 expectedVector)
//        {
//            Assert.Equal(expectedVector, point2 - point1);
//            Assert.Equal(expectedVector, Point2.Displacement(point2, point1));
//        }

//        public IEnumerable<TestCaseData> SizeAdditionTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Size2(), new Point2()).SetName(
//                        "The size addition of the zero point with the empty size is the zero point.");
//                yield return
//                    new TestCaseData(new Point2(5, 5), new Size2(15, 15), new Point2(20, 20)).SetName(
//                        "The size addition of a non-zero point with a non-empty size is the expected point.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(SizeAdditionTestCases))]
//        public void SizeAdditon(Point2 point, Size2 size, Point2 expectedPoint)
//        {
//            Assert.Equal(expectedPoint, point + size);
//            Assert.Equal(expectedPoint, Point2.Add(point, size));
//        }

//        public IEnumerable<TestCaseData> SizeSubtractionTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Size2(), new Point2()).SetName(
//                        "The size substraction of the zero point with the empty size is the zero point.");
//                yield return
//                    new TestCaseData(new Point2(5, 5), new Size2(15, 15), new Point2(-10, -10)).SetName(
//                        "The size subscration of a non-zero point with a non-empty size is the expected point.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(SizeSubtractionTestCases))]
//        public void SizeSubtraction(Point2 point, Size2 size, Point2 expectedPoint)
//        {
//            Assert.Equal(expectedPoint, point - size);
//            Assert.Equal(expectedPoint, Point2.Subtract(point, size));
//        }

//        public IEnumerable<TestCaseData> MinimumTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Point2(), new Point2()).SetName(
//                        "The minimum coordinates of two zero points is the coordinates of the zero point.");
//                yield return
//                    new TestCaseData(new Point2(float.MaxValue, float.MinValue), new Point2(int.MaxValue, int.MinValue),
//                        new Point2(int.MaxValue, float.MinValue)).SetName(
//                        "The minimum coordaintes of two non-zero points is the expected coordinates.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(MinimumTestCases))]
//        public void Minimum(Point2 point1, Point2 point2, Point2 expectedPoint)
//        {
//            var actualPoint = Point2.Minimum(point1, point2);
//            Assert.Equal(expectedPoint, actualPoint);
//        }

//        public IEnumerable<TestCaseData> MaximumTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Point2(), new Point2()).SetName(
//                        "The maximum coordinates of two zero points is the coordinates of the zero point.");
//                yield return
//                    new TestCaseData(new Point2(float.MaxValue, float.MinValue), new Point2(int.MaxValue, int.MinValue),
//                        new Point2(float.MaxValue, int.MinValue)).SetName(
//                        "The maximum coordaintes of two non-zero points is the expected coordinates.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(MaximumTestCases))]
//        public void Maximum(Point2 point1, Point2 point2, Point2 expectedPoint)
//        {
//            var actualPoint = Point2.Maximum(point1, point2);
//            Assert.Equal(expectedPoint, actualPoint);
//        }

//        public IEnumerable<TestCaseData> EqualityTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Point2(), true).SetName("Two zero points are equal.");
//                yield return
//                    new TestCaseData(new Point2(float.MinValue, float.MaxValue),
//                        new Point2(float.MaxValue, float.MinValue), false).SetName(
//                        "Two different non-zero points are not equal.");
//                yield return
//                    new TestCaseData(
//                            new Point2(float.MinValue, float.MaxValue), new Point2(float.MinValue, float.MaxValue), true)
//                        .SetName(
//                            "Two identical non-zero points are equal.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(EqualityTestCases))]
//        public void Equality(Point2 point1, Point2 point2, bool expectedToBeEqual)
//        {
//            Assert.IsTrue(Equals(point1, point2) == expectedToBeEqual);
//            Assert.IsTrue(point1 == point2 == expectedToBeEqual);
//            Assert.IsFalse(point1 == point2 != expectedToBeEqual);
//            Assert.IsTrue(point1.Equals(point2) == expectedToBeEqual);

//            if (expectedToBeEqual)
//                Assert.Equal(point1.GetHashCode(), point2.GetHashCode());
//        }

//        public IEnumerable<TestCaseData> InequalityTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), null, false).SetName("A point is not equal to a null object.");
//                yield return
//                    new TestCaseData(new Point2(), new object(), false).SetName(
//                        "A point is not equal to an instantiated object.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(InequalityTestCases))]
//        public void Inequality(Point2 point, object obj, bool expectedToBeEqual)
//        {
//            Assert.IsTrue(point.Equals(obj) == expectedToBeEqual);
//        }

//        public IEnumerable<TestCaseData> HashCodeTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Point2(), true).SetName(
//                        "Two zero points have the same hash code.");
//                yield return
//                    new TestCaseData(new Point2(50, 50), new Point2(50, 50), true).SetName(
//                        "Two indentical non-zero points have the same hash code.");
//                yield return
//                    new TestCaseData(new Point2(0, 0), new Point2(50, 50), false).SetName(
//                        "Two different non-zero points do not have the same hash code.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(HashCodeTestCases))]
//        public void HashCode(Point2 point1, Point2 point2, bool expectedThatHashCodesAreEqual)
//        {
//            var hashCode1 = point1.GetHashCode();
//            var hashCode2 = point2.GetHashCode();
//            if (expectedThatHashCodesAreEqual)
//                Assert.Equal(hashCode1, hashCode2);
//            else
//                Assert.AreNotEqual(hashCode1, hashCode2);
//        }

//        public IEnumerable<TestCaseData> ToVectorTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(), new Vector2()).SetName(
//                        "The zero point converted to a vector is the zero vector.");
//                yield return
//                    new TestCaseData(new Point2(float.MinValue, float.MaxValue),
//                        new Vector2(float.MinValue, float.MaxValue)).SetName(
//                        "A non-zero point converted to a vector is the expected vector.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(ToVectorTestCases))]
//        public void ToVector(Point2 point, Vector2 expectedVector)
//        {
//            var actualVector = (Vector2)point;
//            Assert.Equal(expectedVector, actualVector);
//        }

//        public IEnumerable<TestCaseData> FromVectorTestCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Vector2(), new Point2()).SetName(
//                        "The zero vector converted to a point is the zero point.");
//                yield return
//                    new TestCaseData(new Vector2(float.MinValue, float.MaxValue),
//                        new Point2(float.MinValue, float.MaxValue)).SetName(
//                        "A non-zero vector converted to a point is the expected point.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(FromVectorTestCases))]
//        public void FromVector(Vector2 vector, Point2 expectedPoint)
//        {
//            var actualPoint = (Point2)vector;
//            Assert.Equal(expectedPoint, actualPoint);
//        }

//        public IEnumerable<TestCaseData> StringCases
//        {
//            get
//            {
//                yield return
//                    new TestCaseData(new Point2(),
//                        string.Format(CultureInfo.CurrentCulture, "({0}, {1})", 0, 0)).SetName(
//                        "The zero point has the expected string representation using the current culture.");
//                yield return new TestCaseData(new Point2(5.1f, -5.123f),
//                    string.Format(CultureInfo.CurrentCulture, "({0}, {1})", 5.1f, -5.123f)).SetName(
//                    "A non-zero point has the expected string representation using the current culture.");
//            }
//        }

//        [Fact]
//        [TestCaseSource(nameof(StringCases))]
//        public void String(Point2 point, string expectedString)
//        {
//            var actualString = point.ToString();
//            Assert.Equal(expectedString, actualString);
//        }
//    }
//}