public void When_FindAngleToVectors_Expect_InsideValidInterval() { Vect3 baseVector = new Vect3(1, 0, 0); Vect3 movingVector = new Vect3(1, 0, 0); for (int newX = -10; newX <= 10; newX++) { movingVector.x = newX; for (int newY = -10; newY <= 10; newY++) { movingVector.y = newY; for (int newZ = -10; newZ <= 10; newZ++) { movingVector.z = newZ; if (movingVector.Equals(Vect3.Zero)) { continue; } Assert.LessOrEqual(movingVector.AngleTo(baseVector), 180, "Invalid angle found for {0} and {1}: {2}", movingVector, baseVector, movingVector.AngleTo(baseVector)); Assert.GreaterOrEqual(movingVector.AngleTo(baseVector), 0, "Invalid angle found for {0} and {1}: {2}", movingVector, baseVector, movingVector.AngleTo(baseVector)); Assert.LessOrEqual(baseVector.AngleTo(movingVector), 180, "Invalid angle found for {0} and {1}: {2}", baseVector, movingVector, baseVector.AngleTo(movingVector)); Assert.GreaterOrEqual(baseVector.AngleTo(movingVector), 0, "Invalid angle found for {0} and {1}: {2}", baseVector, movingVector, baseVector.AngleTo(movingVector)); Assert.That(Util.NearlyEqual(movingVector.AngleTo(baseVector), baseVector.AngleTo(movingVector))); } } } }
public void Equality() { var a = new Vect3(2.0, 3.0, 5.0); var b = new Vect3(2.0, 3.0, 5.0); var c = new Vect3(3.0, 3.0, 6.0); var d = a; Assert.IsTrue(a.Equals(b)); Assert.IsFalse(a.Equals(c)); Assert.IsTrue(a.Equals(d)); Assert.AreEqual(a, b); Assert.AreNotEqual(a, c); Assert.AreEqual(a, d); Assert.IsTrue(a == b); Assert.IsTrue(a != c); Assert.IsTrue(a != null); }
public override bool Equals(Object obj) { //Check for null and compare run-time types. if ((obj == null) || !this.GetType().Equals(obj.GetType())) { return(false); } else { Node other = (Node)obj; return(System.Linq.Enumerable.SequenceEqual(neighbors, other.neighbors) && (coordinate.Equals(other.coordinate) && index.Equals(other.index))); } }