A game about forced loneliness, made by TACStudios
1using System;
2using System.Collections.Generic;
3
4namespace UnityEngine.TestTools.Utils
5{
6 /// <summary>
7 /// Use these classes to compare two objects of the same type for equality within the range of a given tolerance using NUnit or custom constraints . Call Instance to apply the default calculation error value to the comparison.
8 /// </summary>
9 public class Vector3ComparerWithEqualsOperator : IEqualityComparer<Vector3>
10 {
11 private static readonly Vector3ComparerWithEqualsOperator m_Instance = new Vector3ComparerWithEqualsOperator();
12 /// <summary>
13 /// A singleton instance of the comparer with a predefined default error value.
14 /// </summary>
15 public static Vector3ComparerWithEqualsOperator Instance { get { return m_Instance; } }
16
17 private Vector3ComparerWithEqualsOperator() {}
18 /// <summary>
19 /// Compares the actual and expected objects for equality using a custom comparison mechanism.
20 /// </summary>
21 /// <param name="expected">Expected Vector3 used to compare</param>
22 /// <param name="actual">Actual Vector3 value to test.</param>
23 /// <returns>Returns true if expected and actual objects are equal, otherwise it returns false.</returns>
24 /// <example>
25 /// <code>
26 /// [TestFixture]
27 /// public class Vector3Test
28 /// {
29 /// [Test]
30 /// public void VerifyThat_TwoVector3ObjectsAreEqual()
31 /// {
32 /// var actual = new Vector2(10e-7f, 10e-7f, 10e-7f);
33 /// var expected = new Vector2(0f, 0f, 0f);
34 ///
35 /// Assert.That(actual, Is.EqualTo(expected).Using(Vector3ComparerWithEqualsOperator.Instance));
36 /// }
37 /// }
38 /// </code>
39 /// </example>
40 public bool Equals(Vector3 expected, Vector3 actual)
41 {
42 return expected == actual;
43 }
44
45 /// <summary>
46 /// Serves as the default hash function.
47 /// </summary>
48 /// <param name="vec3"> A not null Vector3 object</param>
49 /// <returns>Returns 0</returns>
50 public int GetHashCode(Vector3 vec3)
51 {
52 return 0;
53 }
54 }
55}