public void CheckEmptyStringIsPalindromeTest()
        {
            PalindromeChecker checker = new PalindromeChecker();

            Assert.IsTrue(checker.Check(""));
        }
        public void CheckStringLength2N1IsNotPalindromeTest()
        {
            PalindromeChecker checker = new PalindromeChecker();

            Assert.IsFalse(checker.Check("ABCBC"));
        }
 public void Setup()
 {
     _palindromeChecker = new PalindromeChecker();
 }
Beispiel #4
0
 public PalindromeServiceShould()
 {
     _palindromeChecker = new PalindromeChecker();
 }
        public void PalindromeChecker_WithStringShorterThanTwoChars_ReturnFalse(string value, bool expectedValue)
        {
            var result = PalindromeChecker.Check(value);

            Assert.AreEqual(expectedValue, result);
        }
 public void TestCleanup()
 {
     palindromeChecker = null;
 }
 public void TestInitialize()
 {
     palindromeChecker = new PalindromeChecker();
 }
        public void PalindromeChecker_WithSimplePalindromeStrings_ReturnTrue(string value, bool expectedValue)
        {
            var result = PalindromeChecker.Check(value);

            Assert.AreEqual(expectedValue, result);
        }
 public void Setup()
 {
     _palindromeChecker = new PalindromeChecker();
 }
Beispiel #10
0
 /// <summary>
 /// Run the check
 /// </summary>
 protected override void WhenIRun()
 {
     this.Actual = PalindromeChecker.IsPalindrome(this._phrase);
 }
Beispiel #11
0
        public void IsPalindromeFalse(string input)
        {
            var palindrome = new PalindromeChecker(input);

            Assert.False(palindrome.IsPalindrome);
        }
Beispiel #12
0
        public void CanReverseString(string input, string expected)
        {
            var palindrome = new PalindromeChecker(input);

            Assert.Equal(expected, palindrome._reversed);
        }
Beispiel #13
0
        public void CanRemovePunctuation(string input, string expected)
        {
            var palindrome = new PalindromeChecker(input);

            Assert.Equal(expected, palindrome._withoutPunctuation);
        }
Beispiel #14
0
 private static bool NumberIsPalindrome(int palindromeCandidate)
 {
     return(PalindromeChecker.NumberIsPalindrome(palindromeCandidate));
 }
 public void TestCleanup()
 {
     palindromeChecker = null;
 }
Beispiel #16
0
        public void CanRemoveWhitespace(string input, string expected)
        {
            var palindrome = new PalindromeChecker(input);

            Assert.Equal(expected, palindrome._withoutWhitespace);
        }
        public void IsPalindrome_ChecksIfStringIsPalindrome_False()
        {
            PalindromeChecker testPalindromeChecker = new PalindromeChecker("Grapefruit");

            Assert.AreEqual(false, testPalindromeChecker.IsPalindrome());
        }
        public void PalindromeChecker_WithNonPalindromeStringsWithWhiteSymbols_ReturnFalse(string value, bool expectedValue)
        {
            var result = PalindromeChecker.Check(value);

            Assert.AreEqual(expectedValue, result);
        }
        public void IsPalindrome_ChecksIfStringIsPalidrome_True()
        {
            PalindromeChecker testPalindromeChecker = new PalindromeChecker("hannah");

            Assert.AreEqual(true, testPalindromeChecker.IsPalindrome());
        }
        public void PalindromeChecker_WithNonPalindomsContainsUpperCaseLetters_ReturnFalse(string value, bool expectedValue)
        {
            var result = PalindromeChecker.Check(value);

            Assert.AreEqual(expectedValue, result);
        }
        public void IsPalindrome_ChecksIfMixedCaseStringIsPalidrome_True()
        {
            PalindromeChecker testPalindromeChecker = new PalindromeChecker("HanNah");

            Assert.AreEqual(true, testPalindromeChecker.IsPalindrome());
        }
 public void TestInitialize()
 {
     palindromeChecker = new PalindromeChecker();
 }
        public void PalindromeCheckerConstructor_ConstructsInstanceOfClass_Hello()
        {
            PalindromeChecker testPalindromeChecker = new PalindromeChecker("HELLO");

            Assert.AreEqual("HELLO", testPalindromeChecker.Input);
        }
Beispiel #24
0
        public void RunDemo()
        {
            if (RunSortedListDemo)
            {
                SortedListWithArrayList list = new SortedListWithArrayList();

                list.Add(56);

                list.Add(12);

                list.Add(98);

                list.Add(45);

                list.Add(7);

                list.Add(3);

                list.Add(1);

                list.Add(78);

                list.Add(4478);

                list.Add(-67);

                list.Add(-198);

                list.Add(6);

                list.Add(9);

                Printer.PrintToMedium(list.Print());
            }

            if (RunSortedArrayDemo)
            {
                SortedListWithArray array = new SortedListWithArray();

                array.Add(56);

                array.Add(12);

                array.Add(98);

                array.Add(45);

                array.Add(7);

                array.Add(3);

                array.Add(1);

                array.Add(78);

                array.Add(4478);

                array.Add(-67);

                array.Add(-198);

                array.Add(6);

                array.Add(9);

                Printer.PrintToMedium(array.Print());
            }

            if (RunGraphDemo)
            {
                Graph graph = new Graph();

                graph.Add(-5, 3);

                graph.Add(-2, 5);

                graph.Add(1, -4);

                graph.Add(4, 5);

                graph.Add(6, 4);

                Printer.PrintToMedium(graph.Print());

                GraphTuple[] mins = graph.GetLocalMin(-5, 6);

                foreach (GraphTuple tuple in mins)
                {
                    Printer.PrintToMedium(string.Format("({0},{1})", tuple.X, tuple.Y));
                }
            }

            if (RunCustomIteratorDemo)
            {
                List <int> test1 = new List <int>()
                {
                    1, 2, 3, 4, 5, 6
                };

                List <int> test2 = new List <int>()
                {
                    7, 8, 9, 10, 11, 12
                };

                List <int> test3 = new List <int>()
                {
                    13, 14, 15, 16, 17, 18
                };

                List <int> test4 = new List <int>()
                {
                    19, 20, 21, 22, 23, 24
                };

                List <int> test5 = new List <int>()
                {
                    25, 26, 27, 28, 29, 30
                };

                CustomIteratorList iteratorList = new CustomIteratorList();

                iteratorList.Add(test1);

                iteratorList.Add(test2);

                iteratorList.Add(test3);

                iteratorList.Add(test4);

                iteratorList.Add(test5);

                Printer.PrintToMedium(iteratorList.Print());
            }

            if (RunPalindromeDemo)
            {
                string testString = "mom";

                string testString2 = "12345654321";

                string testString3 = "fafasdfasd";

                string testString4 = "bob";

                Printer.PrintToMedium(string.Format("{0}: {1}", testString, PalindromeChecker.IsMatch(testString)));

                Printer.PrintToMedium(string.Format("{0}: {1}", testString2, PalindromeChecker.IsMatch(testString2)));

                Printer.PrintToMedium(string.Format("{0}: {1}", testString3, PalindromeChecker.IsMatch(testString3)));

                Printer.PrintToMedium(string.Format("{0}: {1}", testString4, PalindromeChecker.IsMatch(testString4)));
            }

            if (RunWorldPopulationCounter)
            {
                int population = WorldPopulationCounter.EstimatePopulation(new DateTime(2099, 5, 23));

                Printer.PrintToMedium(string.Format("Population on 5/23/2099 is: {0}", population));
            }

            if (RunSetDemo)
            {
                MathSet set = new MathSet();

                set.Add(10);

                set.Add(5);

                set.Add(5);

                set.Add(15);

                set.Add(89);

                set.Add(7);

                set.Add(98);

                Printer.PrintToMedium(set.Print());
            }

            if (RunInsertionSort)
            {
                int[] array = new int[] { 1, 10, 56, -45, 89, 4, -976, 100, 45 };

                InsertionSort.Sort(array);

                foreach (int i in array)
                {
                    Console.WriteLine(i);
                }
            }

            if (RunNumberPairsDemo)
            {
                List <int> testList = new List <int>();

                testList.Add(6);

                testList.Add(1);

                testList.Add(3);

                testList.Add(46);

                testList.Add(1);

                testList.Add(3);

                testList.Add(9);

                int numberOfPairs = NumberPairsChecker.NumberOfPairs(testList.ToArray(), 47);

                Printer.PrintToMedium(numberOfPairs.ToString());
            }

            if (RunExpressionValidatorDemo)
            {
                string expression1  = "{[()]}";   //valid
                string expression2  = "{{{}}}";   //valid
                string expression3  = "([({})])"; //valid
                string expression4  = "(()))";    //valid
                string expression5  = "AAAA";     //invalid
                string expression6  = "]]]";
                string expression7  = "}}}";
                string expression8  = "}";
                string expression9  = "{{{}}}]";
                string expression10 = "{";

                List <string> expressions = new List <string>
                {
                    expression1, expression2, expression3, expression4, expression5, expression6, expression7, expression8, expression9, expression10
                };

                for (int i = 0; i < expressions.Count; i++)
                {
                    Printer.PrintToMedium(
                        $"Expression {i + 1} - {expressions[i]} is: {(ExpressionValidator.Validate(expressions[i]) ? "Valid" : "Invalid")}");
                }
            }

            if (RunPathFinderDemo)
            {
                int[][] matrix1 =
                {
                    new[] { 1, 0, 1, 0 },
                    new[] { 1, 1, 0, 0 },
                    new[] { 0, 1, 1, 0 },
                    new[] { 1, 1, 1, 1 },
                };

                int[][] matrix2 =
                {
                    new[] { 1, 0, 1, 0 },
                    new[] { 1, 1, 1, 0 },
                    new[] { 0, 1, 0, 0 },
                    new[] { 1, 1, 1, 1 },
                };

                int[][] matrix3 =
                {
                    new[] { 1, 1, 1, 1 },
                    new[] { 1, 1, 1, 1 },
                    new[] { 1, 1, 1, 1 },
                    new[] { 1, 1, 1, 1 },
                };

                List <Tuple <int, int> > path = PathFinder.FindPath(matrix1);

                Printer.PrintToMedium($"Path for Matrix 1 is");

                foreach (Tuple <int, int> tuple in path)
                {
                    Printer.PrintToMedium($"({tuple.Item1}, {tuple.Item2})");
                }

                path = PathFinder.FindPath(matrix2);

                Printer.PrintToMedium($"Path for Matrix 2 is");

                foreach (Tuple <int, int> tuple in path)
                {
                    Printer.PrintToMedium($"({tuple.Item1}, {tuple.Item2})");
                }

                path = PathFinder.FindPath(matrix3);

                Printer.PrintToMedium($"Path for Matrix 3 is");

                foreach (Tuple <int, int> tuple in path)
                {
                    Printer.PrintToMedium($"({tuple.Item1}, {tuple.Item2})");
                }
            }
        }
 public void IsPalindrome_passing_single_character_returns_true()
 {
     Assert.IsTrue(PalindromeChecker.IsPalindrome("a"));
 }
 public void TestStringFilter()
 {
     Equals(PalindromeChecker.FilterString("23.;]-abc"), "23abc");
 }
 public void IsPalindrome_passing_a_palindrome_phrase_returns_true(string phrase)
 {
     Assert.IsTrue(PalindromeChecker.IsPalindrome(phrase));
 }
        public void CheckStringLength2N1IsPalindromeTest()
        {
            PalindromeChecker checker = new PalindromeChecker();

            Assert.IsTrue(checker.Check("ABCBA"));
        }
 public void IsPalindrome_passing_no_palindrome_phrase_returns_false(string input)
 {
     Assert.IsFalse(PalindromeChecker.IsPalindrome(input));
 }
        public void Test_IsWordPalindrome_ShouldReturnTrue(string word)
        {
            PalindromeChecker palindromeChecker = new PalindromeChecker();

            Assert.True(palindromeChecker.IsWordPalindrome(word));
        }
 public void IsPalindrome_passing_empty_returns_true()
 {
     Assert.IsTrue(PalindromeChecker.IsPalindrome(""));
 }
 public void PalindromeTest(string source, bool isPalindrome)
 {
     Assert.Equal(isPalindrome, PalindromeChecker.IsPalindrome(Node <string> .FromString(source)));
 }
Beispiel #33
0
 public void TestMethod6()
 {
     Console.WriteLine($"never odd, or even: {PalindromeChecker.IsPalindrome("never odd, or even")}");
 }