示例#1
0
        private void buttonEqually_Click(object sender, EventArgs e)
        {
            //НУЖНО добавить - если в поле просто число, то ничего не делать

            int position = textBoxEntry.SelectionStart;

            if (!textBoxEntry.Text.Contains("=") &&
                CorrectSpellingExpressionChecker.SpellingIsCorrect(textBoxEntry.Text))
            {
                string sendingExpression = textBoxEntry.Text;
                double answer            = StringExpressionSolver.GetAnswer(sendingExpression);
                textBoxEntry.Text += "=";
                textBoxResult.Text = answer.ToString();
                textBoxEntry.SetCursor(textBoxEntry.Text.Length);
            }
            else
            {
                MessageBox.Show("Syntax error!", "Attention!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxEntry.SetCursor(position);
            }
        }
 public void TestCases(string input, bool expectedResult)
 {
     Assert.AreEqual(expectedResult,
                     CorrectSpellingExpressionChecker.SpellingIsCorrect(input));
 }