Exemplo n.º 1
0
 //Дециметр
 private void textBox3_TextChanged(object sender, EventArgs e)
 {
     if (!activeTextBox)
     {
         if (textBox3.Text != "")
         {
             try
             {
                 activeTextBox = true;
                 double lenght = Convert.ToDouble(textBox3.Text);
                 Dm     dm     = new Dm();
                 textBox1.Text  = Convert.ToString(dm.getMetr(lenght));
                 textBox2.Text  = Convert.ToString(dm.getSm(lenght));
                 textBox4.Text  = Convert.ToString(dm.getMm(lenght));
                 textBox5.Text  = Convert.ToString(dm.getVershok(lenght));
                 textBox6.Text  = Convert.ToString(dm.getPyad(lenght));
                 textBox7.Text  = Convert.ToString(dm.getArshin(lenght));
                 textBox8.Text  = Convert.ToString(dm.getSagen(lenght));
                 textBox9.Text  = Convert.ToString(dm.getFoot(lenght));
                 textBox10.Text = Convert.ToString(dm.getInch(lenght));
                 textBox11.Text = Convert.ToString(dm.getCable(lenght));
                 textBox12.Text = Convert.ToString(dm.getYard(lenght));
             }
             catch (Exception)
             {
                 MessageBox.Show("Ошибка в вводимого значения");
                 textBox3.Clear();
             }
             activeTextBox = false;
         }
     }
 }
Exemplo n.º 2
0
        public void TestDm()
        {
            Dm     dm     = new Dm();
            double result = dm.getMetr(8);

            Assert.AreEqual(result, 0.8, 0.001, "Ошибка конвертации");
            result = dm.getSm(8);
            Assert.AreEqual(result, 80, 0.001, "Ошибка конвертации");
            result = dm.getMm(8);
            Assert.AreEqual(result, 800, 0.001, "Ошибка конвертации");
            result = dm.getVershok(8);
            Assert.AreEqual(result, 18, 0.001, "Ошибка конвертации");
            result = dm.getPyad(8);
            Assert.AreEqual(result, 4.496, 0.001, "Ошибка конвертации");
            result = dm.getArshin(8);
            Assert.AreEqual(result, 1.128, 0.001, "Ошибка конвертации");
            result = dm.getSagen(8);
            Assert.AreEqual(result, 0.3752, 0.001, "Ошибка конвертации");
        }