public void TestPalindrome_IfNumber1234554321_ReturnsTrue()
        {
            // Act
            bool result = _palindromeAlgorithm.IsPalindrome(1234554321);

            // Assert
            this._expected = true;
            this._actual   = result;

            Assert.AreEqual(this._expected, this._actual);
        }
예제 #2
0
        public void TestApplication_IfNumber99999_ReturnsPalindromeProduct()
        {
            // Arrange
            PalindromeAlgorithm palindromeAlgorithm = new PalindromeAlgorithm();

            // Act
            this._data = this._application.GetLargestPrimePalindrome();
            long product = this._data.StoredResult;

            // Assert
            const bool expected = true;
            bool       actual   = palindromeAlgorithm.IsPalindrome(product);

            Assert.AreEqual(expected, actual);
        }
        /// <summary>
        /// Return the largest possible product of two prime numbers which is a palindrome
        /// </summary>
        public Data GetLargestPrimePalindrome()
        {
            GeneratePrimeNumbersList(this._digitMaximum);

            do
            {
                foreach (var number in this._primeNumbersList)
                {
                    SetPrimeMultipliers(number);
                    SetPrimeProduct();

                    this._palindrome = _palindromeAlgorithm.IsPalindrome(this._primeProduct);
                    if (this._palindrome)
                    {
                        CompareResults();
                    }
                }
                SetupNewSearch();
            } while (this._nextPrimeNumber != null);

            return(_data);
        }