示例#1
0
        public void DecideBestSolutionTest_Invalid_ShouldReturnNull()
        {
            //Arrange
            var solutionList = new List <Solution>()
            {
                new Solution()
                {
                    IsSolved = false, TotalPath = 15
                },
                new Solution()
                {
                    IsSolved = false, TotalPath = 1
                },
                new Solution()
                {
                    IsSolved = false, TotalPath = 10
                },
            };

            //Act
            var solution = PCVAGraphSolver.DecideBestSolution(solutionList);

            //Assert
            Assert.IsNull(solution);
        }
示例#2
0
        public void DecideBestSolutionTest_Valid_ShouldReturnTheShortest()
        {
            //Arrange
            var solutionList = new List <Solution>()
            {
                new Solution()
                {
                    IsSolved = true, TotalPath = 15
                },
                new Solution()
                {
                    IsSolved = false, TotalPath = 1
                },
                new Solution()
                {
                    IsSolved = true, TotalPath = 10
                },
            };

            //Act
            var solution = PCVAGraphSolver.DecideBestSolution(solutionList);

            //Assert
            Assert.IsNotNull(solution);
            Assert.AreEqual(10, solution.TotalPath);
        }
示例#3
0
        public void VerifyTest_InvalidCity_ShouldThrow()
        {
            //Arrange
            var emptySolver = new PCVAGraphSolver(new List <City>());

            //Act - Asset
            Assert.Throws <ArgumentException>(() => emptySolver.VerifyInputs("TESTE1", "TESTE2"));
        }
示例#4
0
        public void GetOrCreateCityTest_NewCity_ShouldAdd()
        {
            //Arrange
            var solver = new PCVAGraphSolver();

            //Act
            var city = solver.GetOrAddCity("newCity");

            //Assert
            Assert.AreEqual(1, solver.AllCities.Count());
            Assert.AreEqual("newCity", solver.AllCities.First().Name);
            Assert.AreEqual(0, solver.AllCities.First().Paths.Count());

            Assert.AreEqual("newCity", city.Name);
            Assert.AreEqual(0, city.Paths.Count());
        }
示例#5
0
        public void GetOrCreateCityTest_GetCity_ShouldGet()
        {
            //Arrange
            var solver = new PCVAGraphSolver(new List <City>()
            {
                new City()
                {
                    Name = "oldCity"
                }
            });

            //Act
            var city = solver.GetOrAddCity("oldCity");

            //Assert
            Assert.AreEqual(1, solver.AllCities.Count());
            Assert.AreEqual("oldCity", solver.AllCities.First().Name);
            Assert.AreEqual("oldCity", city.Name);
        }
示例#6
0
        static void Main(string[] args)
        {
            //Emulando DI
            IIOPort     _IOPort     = new IOPortAdapter();
            IPCVASolver _pcvaSolver = new PCVAGraphSolver();

            var arcsFileName     = "Files/trechos.txt";
            var problemsFileName = "Files/encomendas.txt";
            var solutionFileName = "Files/rotas.txt";

            try
            {
                ExecuteSolver(_IOPort, _pcvaSolver, arcsFileName, problemsFileName, solutionFileName);
                Console.WriteLine($"Output in {solutionFileName}; Press any key to close;");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception thrown: {e.Message}; Press any key to close;");
                Console.ReadKey();
            }
        }
示例#7
0
        public void Setup()
        {
            var pathLists1 = new List <RoadPath>()
            {
                new RoadPath("TESTE2", 1),
                new RoadPath("TESTE3", 3)
            };

            var pathLists2 = new List <RoadPath>()
            {
                new RoadPath("TESTE1", 1),
                new RoadPath("TESTE3", 3)
            };

            var pathLists3 = new List <RoadPath>()
            {
                new RoadPath("TESTE1", 1),
                new RoadPath("TESTE2", 3)
            };

            _allCities = new List <City>
            {
                new City()
                {
                    Name = "TESTE1", Paths = pathLists1
                },
                new City()
                {
                    Name = "TESTE2", Paths = pathLists2
                },
                new City()
                {
                    Name = "TESTE3", Paths = pathLists3
                }
            };

            _solver = new PCVAGraphSolver(_allCities);
        }
示例#8
0
        public void Setup()
        {
            var pathListsRC = new List <RoadPath>()
            {
                new RoadPath("LS", 2),
            };

            var pathListsLS = new List <RoadPath>()
            {
                new RoadPath("LV", 1),
                new RoadPath("SF", 1),
                new RoadPath("RC", 1),
            };

            var pathListsLV = new List <RoadPath>()
            {
                new RoadPath("BC", 1),
                new RoadPath("SF", 2),
                new RoadPath("LS", 1),
            };

            var pathListsSF = new List <RoadPath>()
            {
                new RoadPath("LV", 2),
                new RoadPath("WS", 1),
                new RoadPath("LS", 2),
            };

            var pathListsWS = new List <RoadPath>()
            {
                new RoadPath("SF", 2),
            };

            var pathListsBC = new List <RoadPath>()
            {
                new RoadPath("LV", 1),
            };

            _allCities = new List <City>
            {
                new City()
                {
                    Name = "RC", Paths = pathListsRC
                },
                new City()
                {
                    Name = "LS", Paths = pathListsLS
                },
                new City()
                {
                    Name = "LV", Paths = pathListsLV
                },
                new City()
                {
                    Name = "SF", Paths = pathListsSF
                },
                new City()
                {
                    Name = "WS", Paths = pathListsWS
                },
                new City()
                {
                    Name = "BC", Paths = pathListsBC
                },
                new City()
                {
                    Name = "BH"
                }
            };

            _solver = new PCVAGraphSolver(_allCities);
        }