Пример #1
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();
                }
            }
        }
        public void GetNthFib_Should_ReturnOne_When_GivenTwoAsInput()
        {
            //arrange
            var input = 2;

            //act
            var result = NthFibonacci.GetNthFib(input);

            //assert
            Assert.That(result, Is.EqualTo(1));
        }
        public void NthFibonacciTests()
        {
            //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 = false;

            //TODO check all test comments to ensure they are accurate
            if (PassCondition == true)
            {//Proper test for nth Fibonacci
                Assert.Equal(3, NthFibonacci.GetNthFib(4));
            }
            else
            { //to set inital test to false
                Assert.Equal(1, 2);
            }
        }