Esempio n. 1
0
        public static Passenger Searching(Routing path, Car myCar, List <Passenger> passengers, Passenger nearestPassenger)
        {
            Console.WriteLine("-------Utas keresése--------");
            int nearestPassangerDistance = path.FindRoute(myCar.Position.PosX, myCar.Position.PosY, passengers[0].Position.PosX, passengers[0].Position.PosY, myCar).ToPositions().Count;

            nearestPassenger = passengers[0];
            for (int i = 1; i < passengers.Count; i++)
            {
                int passangerDistance = path.FindRoute(myCar.Position.PosX, myCar.Position.PosY, passengers[i].Position.PosX, passengers[i].Position.PosY, myCar).ToPositions().Count;
                if (nearestPassangerDistance > passangerDistance && nearestPassangerDistance != 2)
                {
                    nearestPassenger = passengers[i];
                }
            }
            return(nearestPassenger);
        }
Esempio n. 2
0
        public void FindRoute_ThrowsAnExcpetionWhenNotRoutesMatched()
        {
            var routing = new Routing();

            routing.RegisterRoute(_simpleRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary<string, string>() { { "path", @"c:\temp\" } });
        }
Esempio n. 3
0
        public void FindRoute_CanFindASimpleRoute()
        {
            var routing = new Routing();
            routing.RegisterRoute(_simpleRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary<string, string>());

            Assert.AreEqual(_simpleRoute, matchedRoute);
        }
Esempio n. 4
0
        public void FindRoute_CanFindASimpleRoute()
        {
            var routing = new Routing();

            routing.RegisterRoute(_simpleRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary <string, string>());

            Assert.AreEqual(_simpleRoute, matchedRoute);
        }
Esempio n. 5
0
        public void FindRoute_CanFindARouteWithDashInName()
        {
            var routing = new Routing();

            routing.RegisterRoute("import-keys", new Dictionary<string, ParameterType>() { { "path", ParameterType.Required } }, (p, c, s) => { }, "");

            var matchedRoute = routing.FindRoute("import-keys", new Dictionary<string, string>() { { "path", @"c:\temp\" } });

            Assert.AreEqual("import-keys", matchedRoute.Name);
        }
Esempio n. 6
0
        public void FindRoute_ThrowsAnExcpetionWhenNotRoutesMatched()
        {
            var routing = new Routing();

            routing.RegisterRoute(_simpleRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary <string, string>()
            {
                { "path", @"c:\temp\" }
            });
        }
Esempio n. 7
0
        public void FindRoute_CanFindARouteWithARequiredParam()
        {
            var routing = new Routing();
            
            routing.RegisterRoute(_simpleRoute);
            routing.RegisterRoute(_singleParamRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary<string, string>() { { "path", @"c:\temp\" } });

            Assert.AreEqual(_singleParamRoute, matchedRoute);
        }
Esempio n. 8
0
        public void FindRoute_CanFindARouteWithARequiredParam()
        {
            var routing = new Routing();

            routing.RegisterRoute(_simpleRoute);
            routing.RegisterRoute(_singleParamRoute);

            var matchedRoute = routing.FindRoute("ls", new Dictionary <string, string>()
            {
                { "path", @"c:\temp\" }
            });

            Assert.AreEqual(_singleParamRoute, matchedRoute);
        }
Esempio n. 9
0
        public void FindRoute_CanFindARouteWithDashInName()
        {
            var routing = new Routing();

            routing.RegisterRoute("import-keys", new Dictionary <string, ParameterType>()
            {
                { "path", ParameterType.Required }
            }, (p, c, s) => { }, "");

            var matchedRoute = routing.FindRoute("import-keys", new Dictionary <string, string>()
            {
                { "path", @"c:\temp\" }
            });

            Assert.AreEqual("import-keys", matchedRoute.Name);
        }