示例#1
0
        public void FindThreeNumsTest()
        {
            //boolean to set test conditions
            //dedault is set to false to create fail condition for test.
            //once fail condition is set, change boolean to true to test
            bool PassCondition = true;

            if (PassCondition == true)
            {//Proper test for FindThreeLargestNumbers
                int[] array = { -5, 0, 2, 203, -6, -100, 62, 45, 12, 7, 55 };

                int[] expectedPass = { 55, 62, 203 };


                int[] actual = FindThreeLargestNumbers.FIndTheThreeLargestNum(array);


                Assert.Equal(expectedPass, actual);
            }
            else
            { //to set inital test to false
                int[] array = { -5, 0, 2, 203, -6, -100, 62, 45, 12, 7, 55 };

                int[] expectedFail = { -5, -6, 0 };

                int[] actual = FindThreeLargestNumbers.FIndTheThreeLargestNum(array);

                Assert.Equal(expectedFail, actual);
            }
        }
示例#2
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                if (currentSelection == "Find three largest numbers in array")
                {
                    int[] array = Array.ConvertAll(UserInputBox.Text.Split(','), int.Parse);
                    AnswerTxtBox.Text = string.Join(",", FindThreeLargestNumbers.FIndTheThreeLargestNum(array));
                }
                else if (currentSelection == "Move elements in array to end")
                {
                    List <int> listOfNums = UserInputBox.Text.Split(',').Select(Int32.Parse).ToList();
                    int        intToMove  = Int32.Parse(AdditionalInputTxtBox.Text);
                    AnswerTxtBox.Text = string.Join("", ElementsToEnd.MoveElementToEnd(listOfNums, intToMove));
                }
                else if (currentSelection == "Palindrome validator")
                {
                    AnswerTxtBox.Text = PalindromeChecker.IsPalindrome(UserInputBox.Text.ToLower()).ToString();
                }
                else if (currentSelection == "Sub sequence validator")
                {
                    List <int> array           = UserInputBox.Text.Split(',').Select(Int32.Parse).ToList();
                    List <int> potentialSubSeq = AdditionalInputTxtBox.Text.Split(',').Select(Int32.Parse).ToList();

                    AnswerTxtBox.Text = SubsetChecker.IsValidSubsequence(array, potentialSubSeq).ToString();
                }
                else if (currentSelection == "Nth Fibonacci")
                {
                    int num = Int32.Parse(UserInputBox.Text);
                    AnswerTxtBox.Text = NthFibonacci.GetNthFib(num).ToString();
                }
            }
        }