示例#1
0
        public void TestCampusMapBLL_GetShortestPath_RouteNotFound()
        {
            // Arrange
            string Node1 = "N1";
            string Node2 = "N2";

            // Action
            CampusMapBLL testObj = new CampusMapBLL(CampusMapBLLTestsUtilities.GetANoRouteCampusMap(Node1, Node2));
            Path         path    = testObj.GetShortestPath(Node1, Node2);

            // Assert
            Assert.IsNotNull(path);
            Assert.AreEqual(float.PositiveInfinity, path.distance);
            Assert.AreEqual(1, path.path.Count);
            Assert.AreEqual(Node1, path.path[0]);
        }
示例#2
0
        public void TestCampusMapBLL_GetShortestPath_RouteFound3Hop()
        {
            // Arrange
            string Node1  = "N1";
            string Node2  = "N2";
            int    nrHops = 3;

            // Action
            CampusMapBLL testObj = new CampusMapBLL(CampusMapBLLTestsUtilities.GetASimpleCampusMap3Hop(Node1, Node2));
            Path         path    = testObj.GetShortestPath(Node1, Node2);

            // Assert
            Assert.IsNotNull(path);
            Assert.AreNotEqual(float.PositiveInfinity, path.distance);
            Assert.AreEqual(nrHops + 1, path.path.Count); // 3 Hops have 4 nodes
            Assert.AreEqual(Node1, path.path[0]);
            Assert.AreEqual(Node2, path.path[nrHops]);
        }
示例#3
0
        public void TestCampusMapBLL_GetShortestPath_RouteFoundWithCircularReference()
        {
            // Arrange
            string Node1  = "N1";
            string Node2  = "N2";
            int    nrHops = 4;

            // Action
            CampusMapBLL testObj = new CampusMapBLL(CampusMapBLLTestsUtilities.GetACampusMapWithCircularReference(Node1, Node2, nrHops));
            Path         path    = testObj.GetShortestPath(Node1, Node2);

            // Assert
            Assert.IsNotNull(path);
            Assert.AreNotEqual(float.PositiveInfinity, path.distance);
            Assert.AreEqual(nrHops + 1, path.path.Count);
            Assert.AreEqual(Node1, path.path[0]);
            Assert.AreEqual(Node2, path.path[nrHops]);
        }
示例#4
0
        public void TestCampusMapBLL_GetShortestPath_RouteFoundDeepWithShortCircuit()
        {
            // Arrange
            string Node1           = "N1";
            string Node2           = "N2";
            int    goodRouteNrHops = 2;
            int    badRouteNrHops  = 3;

            // Action
            CampusMapBLL testObj = new CampusMapBLL(CampusMapBLLTestsUtilities.GetACampusMapWithShortCircuit(Node1, Node2, goodRouteNrHops, badRouteNrHops));
            Path         path    = testObj.GetShortestPath(Node1, Node2);

            // Assert
            Assert.IsNotNull(path);
            Assert.AreNotEqual(float.PositiveInfinity, path.distance);
            Assert.AreEqual(goodRouteNrHops + 1, path.path.Count);// 4 Hops have 5 nodes
            Assert.AreEqual(Node1, path.path[0]);
            Assert.AreEqual(Node2, path.path[goodRouteNrHops]);
        }