Example #1
0
        private void AddNewQuestionButton_Click(object sender, EventArgs e)
        {
            bool status = true;

            if (!validationService.CheckPolishWord(newQuestionTextBox.Text) || newQuestionTextBox.Text == PlaceHolderQuestion)
            {
                MessageBox.Show("Incorrect question!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                status = false;
            }
            else if (!validationService.CheckEnglishWord(newAnswerTextBox.Text) || newAnswerTextBox.Text == PlaceHolderAnswer)
            {
                MessageBox.Show("Incorrect answer!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                status = false;
            }
            else if (!validationService.CheckEnglishWord(newLevelTextBox.Text))
            {
                MessageBox.Show("Incorrect level!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                status = false;
            }

            if (status)
            {
                questionService.AddNewQuestion(newQuestionTextBox.Text, newAnswerTextBox.Text, newLevelTextBox.Text);
                MessageBox.Show($"Added successfully\n{newQuestionTextBox.Text} - {newAnswerTextBox.Text}\nLevel: {newLevelTextBox.Text}", "Information");
                newQuestionTextBox.Text = PlaceHolderQuestion;
                newAnswerTextBox.Text   = PlaceHolderAnswer;
                newLevelTextBox.Text    = PlaceHolderLevel;
            }
        }
Example #2
0
        public void CheckEnglishWordWithWrongWord()
        {
            //Arrange
            string word  = "鄴單";
            string word2 = "car45";
            string word3 = "45car";
            string word4 = "c45ar";
            string word5 = "45";
            string word6 = "";
            string word7 = "car%";

            ValidationService validationService = new ValidationService();

            //Act
            bool polishWord            = validationService.CheckEnglishWord(word);
            bool numbersAtTheEnd       = validationService.CheckEnglishWord(word2);
            bool numbersAtTheBeginning = validationService.CheckEnglishWord(word3);
            bool numbersInside         = validationService.CheckEnglishWord(word4);
            bool onlyNumbers           = validationService.CheckEnglishWord(word5);
            bool nothing      = validationService.CheckEnglishWord(word6);
            bool specialSigns = validationService.CheckEnglishWord(word7);

            //Assert
            polishWord.Should().BeFalse();
            numbersAtTheEnd.Should().BeFalse();
            numbersAtTheBeginning.Should().BeFalse();
            numbersInside.Should().BeFalse();
            onlyNumbers.Should().BeFalse();
            nothing.Should().BeFalse();
            specialSigns.Should().BeFalse();
        }
Example #3
0
        public void CheckEnglishWordWithProperWord()
        {
            //Arrange
            string word = "car";

            ValidationService validationService = new ValidationService();

            //Act
            bool properWord = validationService.CheckEnglishWord(word);

            //Assert
            properWord.Should().BeTrue();
        }