Beispiel #1
0
        public void TestGetNearestVector2()
        {
            // not unit vectors, but okay for test
            Vector2 nearest = VecmathUtil.GetNearestVector(new Vector2(0, -1), new[] { new Vector2(0.5, 0.5), new Vector2(0.5, -0.5) });

            Assert.AreEqual(0.5, nearest.X, 0.01);
            Assert.AreEqual(-0.5, nearest.Y, 0.01);
        }
Beispiel #2
0
        public void TestGetNearestVectorFromBonds()
        {
            var mock_a1 = new Mock <IAtom>(); var a1 = mock_a1.Object;
            var mock_a2 = new Mock <IAtom>(); var a2 = mock_a2.Object;
            var mock_a3 = new Mock <IAtom>(); var a3 = mock_a3.Object;
            var mock_a4 = new Mock <IAtom>(); var a4 = mock_a4.Object;
            var mock_b1 = new Mock <IBond>(); var b1 = mock_b1.Object;
            var mock_b2 = new Mock <IBond>(); var b2 = mock_b2.Object;
            var mock_b3 = new Mock <IBond>(); var b3 = mock_b3.Object;

            mock_b1.Setup(n => n.GetOther(a1)).Returns(a2);
            mock_b2.Setup(n => n.GetOther(a1)).Returns(a3);
            mock_b3.Setup(n => n.GetOther(a1)).Returns(a4);
            mock_a1.Setup(n => n.Point2D).Returns(new Vector2(0, 0));
            mock_a2.Setup(n => n.Point2D).Returns(new Vector2(0, 1));
            mock_a3.Setup(n => n.Point2D).Returns(new Vector2(1, 0));
            mock_a4.Setup(n => n.Point2D).Returns(new Vector2(1, 1)); // this one is found

            Vector2 nearest = VecmathUtil.GetNearestVector(new Vector2(0.5, 0.5), a1, new[] { b1, b2, b3 });

            Assert.AreEqual(0.707, nearest.X, 0.01);
            Assert.AreEqual(0.707, nearest.Y, 0.01);
        }
Beispiel #3
0
 public void TestGetNearestVectorComplainsWhenNoVectorsProvided()
 {
     VecmathUtil.GetNearestVector(new Vector2(1, 0), Array.Empty <Vector2>());
 }