Exemplo n.º 1
0
        public void ResolveMap()
        {
            MapResult expectedResult = new MapResult()
            {
                Letters = "BEEFCAKE", PathChars = "@---+B||E--+|E|+--F--+|C|||A--|-----K|||+--E--Ex"
            };

            char[][] testArray = new char[9][]
            {
                new char[] { ' ', ' ', '@', '-', '-', '-', '+' },
                new char[] { ' ', ' ', ' ', ' ', ' ', ' ', 'B' },
                new char[] { 'K', '-', '-', '-', '-', '-', '|', '-', '-', 'A' },
                new char[] { '|', ' ', ' ', ' ', ' ', ' ', '|', ' ', ' ', '|' },
                new char[] { '|', ' ', ' ', '+', '-', '-', 'E', ' ', ' ', '|' },
                new char[] { '|', ' ', ' ', '|', ' ', ' ', ' ', ' ', ' ', '|' },
                new char[] { '+', '-', '-', 'E', '-', '-', 'E', 'x', ' ', 'C' },
                new char[] { ' ', ' ', ' ', '|', ' ', ' ', ' ', ' ', ' ', '|' },
                new char[] { ' ', ' ', ' ', '+', '-', '-', 'F', '-', '-', '+' },
            };

            var result = AsciiMapService.ResolveMap(testArray);

            Assert.AreEqual(expectedResult.Letters, result.Letters);
            Assert.AreEqual(expectedResult.PathChars, result.PathChars);
        }
        public ActionResult AsciiMapPath(AsciiForm formData)
        {
            if (formData.AsciiMap == null || !ModelState.IsValid)
            {
                return(Json(new { ErrorMessage = "Txt file with ASCII map is required" }, @"application/json"));
            }

            var result = AsciiMapService.ProcessUploadedFile(formData.AsciiMap);

            return(Json(new { MapResult = result }, @"application/json"));
        }