コード例 #1
0
        public void TestNewUnitVectors()
        {
            var mock_fromAtom = new Mock <IAtom>(); var fromAtom = mock_fromAtom.Object;
            var mock_toAtom1 = new Mock <IAtom>(); var toAtom1 = mock_toAtom1.Object;
            var mock_toAtom2 = new Mock <IAtom>(); var toAtom2 = mock_toAtom2.Object;
            var mock_toAtom3 = new Mock <IAtom>(); var toAtom3 = mock_toAtom3.Object;

            mock_fromAtom.Setup(n => n.Point2D).Returns(new Vector2(4, 2));
            mock_toAtom1.Setup(n => n.Point2D).Returns(new Vector2(-5, 3));
            mock_toAtom2.Setup(n => n.Point2D).Returns(new Vector2(6, -4));
            mock_toAtom3.Setup(n => n.Point2D).Returns(new Vector2(7, 5));
            var vectors = VecmathUtil.NewUnitVectors(fromAtom, new[] { toAtom1, toAtom2, toAtom3 });

            Assert.AreEqual(3, vectors.Count);
            Assert.AreEqual(-0.993, vectors[0].X, 0.01);
            Assert.AreEqual(0.110, vectors[0].Y, 0.01);
            Assert.AreEqual(0.316, vectors[1].X, 0.01);
            Assert.AreEqual(-0.948, vectors[1].Y, 0.01);
            Assert.AreEqual(0.707, vectors[2].X, 0.01);
            Assert.AreEqual(0.707, vectors[2].Y, 0.01);
        }