Ejemplo 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);
        }
Ejemplo 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\" } });
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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\" }
            });
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }