示例#1
0
        /// <summary>
        /// Tested den Datenbestand einer Verbindung
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="expectedPoint1"></param>
        /// <param name="expectedPoint2"></param>
        /// <param name="expectedDistance"></param>
        /// <param name="expectedPheromon"></param>
        protected void testConnectionData(CConnection connection, CTSPPoint expectedPoint1, CTSPPoint expectedPoint2, float expectedDistance, float expectedPheromon)
        {
            CTSPPoint testPoint1;
            CTSPPoint testPoint2;

            connection.getPoints(out testPoint1, out testPoint2);

            Assert.AreSame(testPoint1, expectedPoint1);
            Assert.AreSame(testPoint2, expectedPoint2);

            Assert.IsTrue(connection.getDistance() == expectedDistance);
            Assert.IsTrue(connection.getPheromone() == expectedPheromon);
        }
        protected void testTSPFileParser(string fileAdress, int pointToCheck, float expectedX, float expectedY)
        {
            Stream            file       = new FileStream(fileAdress, FileMode.Open);
            CTSPLibFileParser fileParser = new CTSPLibFileParser(file);

            fileParser.fillTSPPointList();
            file.Close();
            CTSPPoint readPoint = CTSPPointList.getInstance().getPoint(pointToCheck);

            if (readPoint == null)
            {
                Assert.Fail("Zu prüfender Punkt konnte nicht geholt werden.");
            }

            Assert.IsTrue(expectedX == readPoint.x, "X-Wert wurde falsch eingelesen");
            Assert.IsTrue(expectedY == readPoint.y, "Y-Wert wurde falsch eingelesen");
        }
示例#3
0
        public void constructorTest()
        {
            CTSPPoint defaultConstrutor = new CTSPPoint();

            testAPoint(defaultConstrutor, 0, 0, "");

            CTSPPoint defaultConstructorLabeled = new CTSPPoint(TEST_LABEL);

            testAPoint(defaultConstructorLabeled, 0, 0, TEST_LABEL);

            CTSPPoint specificConstrutorCoordOnly = new CTSPPoint(X_TEST_VALUE_1, Y_TEST_VALUE_1);

            testAPoint(specificConstrutorCoordOnly, X_TEST_VALUE_1, Y_TEST_VALUE_1, "");

            CTSPPoint specificConstrutor = new CTSPPoint(X_TEST_VALUE_2, Y_TEST_VALUE_2, TEST_LABEL);

            testAPoint(specificConstrutor, X_TEST_VALUE_2, Y_TEST_VALUE_2, TEST_LABEL);
        }
示例#4
0
        public void testGetPoints()
        {
            CTour tour = new CTour();

            tour.addPoint(TEST_POINT_1);
            tour.addPoint(TEST_POINT_2);
            tour.addPoint(TEST_POINT_3);

            CTSPPoint point1 = tour.getPoint(0);

            Assert.AreSame(point1, TEST_POINT_1);

            CTSPPoint point2 = tour.getPoint(1);

            Assert.AreSame(point2, TEST_POINT_2);

            CTSPPoint point3 = tour.getPoint(2);

            Assert.AreSame(point3, TEST_POINT_3);
        }
示例#5
0
 protected void testAPoint(CTSPPoint point, float expectedX, float expectedY, string expectedLabel)
 {
     Assert.IsTrue(point.x == expectedX, "X-Koordinate von CTSPPoint falsch");
     Assert.IsTrue(point.y == expectedY, "Y-Koordinate von CTSPPoint falsch");
     Assert.IsTrue(point.getLabel() == expectedLabel, "Label von CTSPPoint falsch");
 }