コード例 #1
0
        public void PositionITest()
        {
            // standart Constructor
            var position = new PositionI(0, 0);

            Assert.IsNotNull(position);

            // Constructor Position out of a ReagionPosition
            var regionPos = new RegionPosition(0, 0);
            var cellPos   = new CellPosition(0, 0);

            position = new PositionI(regionPos, cellPos);
            Assert.IsNotNull(position);

            position = new PositionI(new Position(0, 0));
            Assert.IsNotNull(position);

            // tests the + Operator
            position = new PositionI(1, 1);
            var position2 = new PositionI(0, 0);

            position2 += position;

            Assert.AreEqual(position, position2);

            // tests the - Operator
            position -= position2;

            Assert.AreNotEqual(position2, position);
            Assert.AreEqual(new PositionI(0, 0), position);

            // tests the == Operator
            Assert.True(new PositionI(0, 0) == position);

            // tests the Equals function
            Assert.True(position.Equals(new PositionI(0, 0)));

            // test Distance with PositionI
            var dist = position.Distance(position2);

            Assert.IsNotNull(dist);

            // test Distance with PositionI
            var dist2 = position2.Distance(new Position(0, 0));

            Assert.IsNotNull(dist2);
            Assert.AreEqual(dist, dist2);
        }
コード例 #2
0
ファイル: Node.cs プロジェクト: Quantenradierer/ascendancy
 /// <summary>
 /// Gets the distance between two points.
 /// </summary>
 /// <returns>The traversal cost.</returns>
 /// <param name="location">Current PositionI</param>
 /// <param name="otherLocation">Other PositionI.</param>
 internal static double GetTraversalCost(PositionI location, PositionI otherLocation)
 {
     return(location.Distance(otherLocation));
 }