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; } }
public void CheckPolishWordWithWrongWord() { //Arrange string word = "鄴單45"; string word2 = "45鄴單"; string word3 = "鄴45單"; string word4 = "45"; string word5 = ""; string word6 = "test%"; ValidationService validationService = new ValidationService(); //Act bool numbersAtTheEnd = validationService.CheckPolishWord(word); bool numbersAtTheBeginning = validationService.CheckPolishWord(word2); bool numbersInside = validationService.CheckPolishWord(word3); bool onlyNumbers = validationService.CheckPolishWord(word4); bool nothing = validationService.CheckPolishWord(word5); bool specialSigns = validationService.CheckPolishWord(word6); //Assert numbersAtTheEnd.Should().BeFalse(); numbersAtTheBeginning.Should().BeFalse(); numbersInside.Should().BeFalse(); onlyNumbers.Should().BeFalse(); nothing.Should().BeFalse(); specialSigns.Should().BeFalse(); }
public void CheckPolishWordWithProperWord() { //Arrange string word = "鄴單"; ValidationService validationService = new ValidationService(); //Act bool properWord = validationService.CheckPolishWord(word); //Assert properWord.Should().BeTrue(); }