Exemplo n.º 1
0
        public void UppercaseTest()
        {
            var expected = "HELLO WORLD";
            var result   = _service.UppercaseAllLettersInString("Hello world");

            Assert.IsTrue(expected == result);
        }
        public JsonResult StringManipulation(string phrase, StringManipulationFunction task)
        {
            if (string.IsNullOrEmpty(phrase))
            {
                return(Json(new { success = false, message = "Phrase is empty" }));
            }
            string resultString;

            switch (task)
            {
            case StringManipulationFunction.Uppercase:
                resultString = _stringManipulationService.UppercaseAllLettersInString(phrase);
                break;

            case StringManipulationFunction.Reverse:
                resultString = _stringManipulationService.ReverseString(phrase);
                break;

            default:
                resultString = null;
                break;
            }
            return(Json(new { success = true, result = resultString }));
        }