コード例 #1
0
ファイル: Form1.cs プロジェクト: Dannyyyy/ValueConverter
 //Аршин
 private void textBox7_TextChanged(object sender, EventArgs e)
 {
     if (!activeTextBox)
     {
         if (textBox7.Text != "")
         {
             try
             {
                 activeTextBox = true;
                 double lenght = Convert.ToDouble(textBox7.Text);
                 Arshin arshin = new Arshin();
                 textBox1.Text  = Convert.ToString(arshin.getMetr(lenght));
                 textBox2.Text  = Convert.ToString(arshin.getSm(lenght));
                 textBox3.Text  = Convert.ToString(arshin.getDm(lenght));
                 textBox4.Text  = Convert.ToString(arshin.getMm(lenght));
                 textBox5.Text  = Convert.ToString(arshin.getVershok(lenght));
                 textBox6.Text  = Convert.ToString(arshin.getPyad(lenght));
                 textBox8.Text  = Convert.ToString(arshin.getSagen(lenght));
                 textBox9.Text  = Convert.ToString(arshin.getFoot(lenght));
                 textBox10.Text = Convert.ToString(arshin.getInch(lenght));
                 textBox11.Text = Convert.ToString(arshin.getCable(lenght));
                 textBox12.Text = Convert.ToString(arshin.getYard(lenght));
             }
             catch (Exception)
             {
                 MessageBox.Show("Ошибка в вводимого значения");
                 textBox7.Clear();
             }
             activeTextBox = false;
         }
     }
 }
コード例 #2
0
        public void TestArshin()
        {
            Arshin arshin = new Arshin();
            double result = arshin.getMetr(5);

            Assert.AreEqual(result, 3.555, 0.001, "Ошибка конвертации");
            result = arshin.getDm(5);
            Assert.AreEqual(result, 35.56, 0.001, "Ошибка конвертации");
            result = arshin.getSm(5);
            Assert.AreEqual(result, 355.6, 0.001, "Ошибка конвертации");
            result = arshin.getMm(5);
            Assert.AreEqual(result, 3556, 0.001, "Ошибка конвертации");
            result = arshin.getVershok(5);
            Assert.AreEqual(result, 80, 0.001, "Ошибка конвертации");
            result = arshin.getPyad(5);
            Assert.AreEqual(result, 20, 0.001, "Ошибка конвертации");
            result = arshin.getSagen(5);
            Assert.AreEqual(result, 1.665, 0.001, "Ошибка конвертации");
        }