Beispiel #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"));
        }
Beispiel #2
0
 public void DoesAThreeDigitNonPalindromeNumberPassTest()
 {
     Assert.IsFalse(ExerciseSixHelpers.IsAPalindrome(506));
 }
Beispiel #3
0
 public void DoesAThreeDigitPalindromeNumberPassTest()
 {
     Assert.IsTrue(ExerciseSixHelpers.IsAPalindrome(101));
 }
Beispiel #4
0
 public void IsZeroAPalindromeTest()
 {
     Assert.IsTrue(ExerciseSixHelpers.IsAPalindrome(0));
 }
Beispiel #5
0
 public void DoesANegativeNumberPassTest()
 {
     Assert.IsFalse(ExerciseSixHelpers.IsAPositiveNumber(-50));
 }
Beispiel #6
0
 public void DoesAPositiveNumberPassTest()
 {
     Assert.IsTrue(ExerciseSixHelpers.IsAPositiveNumber(50));
 }
Beispiel #7
0
 public void IsZeroAPositiveNumberTest()
 {
     Assert.IsTrue(ExerciseSixHelpers.IsAPositiveNumber(0));
 }