public void GeneratePathsText_Success()
        {
            string paths =
                $"LS SF 1 {Environment.NewLine}"
                + $"SF LS 2 {Environment.NewLine}"
                + $"LS LV 1 {Environment.NewLine}"
                + $"LV LS 1 {Environment.NewLine}"
                + $"SF LV 2 {Environment.NewLine}"
                + $"LV SF 2 {Environment.NewLine}"
                + $"LS RC 1 {Environment.NewLine}"
                + $"RC LS 2 {Environment.NewLine}"
                + $"SF WS 1 {Environment.NewLine}"
                + $"WS SF 2 {Environment.NewLine}"
                + $"LV BC 1 {Environment.NewLine}"
                + $"BC LV 1";

            string orders =
                $"SF WS {Environment.NewLine}"
                + $"LS BC {Environment.NewLine}"
                + $"WS BC";

            PathFinderTxtHandler.RegisterPaths(paths);
            var pathsResult = PathFinderTxtHandler.GeneratePathsText(orders, _shortestPathFinder);

            var pathsLines = pathsResult.Split(Environment.NewLine);

            Assert.True(pathsLines.Length == 3);
            Assert.Equal("SF WS 1", pathsLines[0].Trim());
            Assert.Equal("LS LV BC 2", pathsLines[1].Trim());
            Assert.Equal("WS SF LV BC 5", pathsLines[2].Trim());
        }
Exemplo n.º 2
0
        public IActionResult GeneratePathsFile(IFormFile ordersFile)
        {
            var pathsText   = PathFinderTxtHandler.GeneratePathsText(ordersFile.GetText(), _shortestPathFinder);
            var fileContent = Encoding.UTF8.GetBytes(pathsText);

            return(File(new MemoryStream(fileContent), "text/plain", "rotas.txt"));
        }