Example #1
0
 private void textBox10_TextChanged(object sender, EventArgs e)
 {
     if (!activeTextBox)
     {
         if (textBox10.Text != "")
         {
             try
             {
                 activeTextBox = true;
                 double lenght = Convert.ToDouble(textBox10.Text);
                 Inch   inch   = new Inch();
                 textBox1.Text  = Convert.ToString(inch.getMetr(lenght));
                 textBox2.Text  = Convert.ToString(inch.getSm(lenght));
                 textBox3.Text  = Convert.ToString(inch.getDm(lenght));
                 textBox4.Text  = Convert.ToString(inch.getMm(lenght));
                 textBox5.Text  = Convert.ToString(inch.getVershok(lenght));
                 textBox6.Text  = Convert.ToString(inch.getPyad(lenght));
                 textBox7.Text  = Convert.ToString(inch.getArshin(lenght));
                 textBox8.Text  = Convert.ToString(inch.getSagen(lenght));
                 textBox9.Text  = Convert.ToString(inch.getFoot(lenght));
                 textBox11.Text = Convert.ToString(inch.getCable(lenght));
                 textBox12.Text = Convert.ToString(inch.getYard(lenght));
             }
             catch (Exception)
             {
                 MessageBox.Show("Ошибка в вводимого значения");
                 textBox10.Clear();
             }
             activeTextBox = false;
         }
     }
 }
Example #2
0
        public void TestInch()
        {
            Inch   inch   = new Inch();
            double result = inch.getMetr(10);

            Assert.AreEqual(result, 0.254, 0.001, "Ошибка конвертации");
            result = inch.getDm(10);
            Assert.AreEqual(result, 2.54, 0.001, "Ошибка конвертации");
            result = inch.getSm(10);
            Assert.AreEqual(result, 25.4, 0.001, "Ошибка конвертации");
            result = inch.getMm(10);
            Assert.AreEqual(result, 254, 0.001, "Ошибка конвертации");
            result = inch.getVershok(10);
            Assert.AreEqual(result, 5.71, 0.001, "Ошибка конвертации");
            result = inch.getPyad(10);
            Assert.AreEqual(result, 1.43, 0.001, "Ошибка конвертации");
            result = inch.getArshin(10);
            Assert.AreEqual(result, 0.357, 0.001, "Ошибка конвертации");
            result = inch.getSagen(10);
            Assert.AreEqual(result, 0.119, 0.001, "Ошибка конвертации");
            result = inch.getFoot(10);
            Assert.AreEqual(result, 0.833, 0.001, "Ошибка конвертации");
        }