Ejemplo n.º 1
0
        public IActionResult Calculate(ExerciseSix eSix)
        {
            // -- Makes sure we have an integer and the integer is positive
            if (ModelState.IsValid && ExerciseSixHelpers.IsAPositiveNumber(eSix.Number))
            {
                // -- Holds the response from the palindrome calculations
                string validationMessage = ExerciseSixHelpers.IsAPalindrome(eSix.Number) ? $"Passed Test - { eSix.Number } Is A Palindrome" : $"Failed Test - { eSix.Number } Is Not A Palindrome";

                // -- Returns to the index page with the palindrome calculation results
                return(RedirectToAction("Index", new { status = validationMessage }));
            }

            // -- If we failed input validation we want to display a better error for the user rather than the default invalid input
            ReplaceDefaultErrorMessage();

            // -- return to the inputted page with the error.
            return(View("Index"));
        }
Ejemplo n.º 2
0
 public void DoesAPositiveNumberPassTest()
 {
     Assert.IsTrue(ExerciseSixHelpers.IsAPositiveNumber(50));
 }
Ejemplo n.º 3
0
 public void DoesANegativeNumberPassTest()
 {
     Assert.IsFalse(ExerciseSixHelpers.IsAPositiveNumber(-50));
 }
Ejemplo n.º 4
0
 public void IsZeroAPositiveNumberTest()
 {
     Assert.IsTrue(ExerciseSixHelpers.IsAPositiveNumber(0));
 }