//Миллиметр private void textBox4_TextChanged(object sender, EventArgs e) { if (!activeTextBox) { if (textBox4.Text != "") { try { activeTextBox = true; double lenght = Convert.ToDouble(textBox4.Text); Mm mm = new Mm(); textBox1.Text = Convert.ToString(mm.getMetr(lenght)); textBox2.Text = Convert.ToString(mm.getSm(lenght)); textBox3.Text = Convert.ToString(mm.getDm(lenght)); textBox5.Text = Convert.ToString(mm.getVershok(lenght)); textBox6.Text = Convert.ToString(mm.getPyad(lenght)); textBox7.Text = Convert.ToString(mm.getArshin(lenght)); textBox8.Text = Convert.ToString(mm.getSagen(lenght)); textBox9.Text = Convert.ToString(mm.getFoot(lenght)); textBox10.Text = Convert.ToString(mm.getInch(lenght)); textBox11.Text = Convert.ToString(mm.getCable(lenght)); textBox12.Text = Convert.ToString(mm.getYard(lenght)); } catch (Exception) { MessageBox.Show("Ошибка в вводимого значения"); textBox4.Clear(); } activeTextBox = false; } } }
public void TestMm() { Mm mm = new Mm(); double result = mm.getMetr(8); Assert.AreEqual(result, 0.008, 0.001, "Ошибка конвертации"); result = mm.getDm(8); Assert.AreEqual(result, 0.08, 0.001, "Ошибка конвертации"); result = mm.getSm(8); Assert.AreEqual(result, 0.8, 0.001, "Ошибка конвертации"); result = mm.getVershok(8); Assert.AreEqual(result, 0.18, 0.001, "Ошибка конвертации"); result = mm.getPyad(8); Assert.AreEqual(result, 0.04496, 0.001, "Ошибка конвертации"); result = mm.getArshin(8); Assert.AreEqual(result, 0.01128, 0.001, "Ошибка конвертации"); result = mm.getSagen(8); Assert.AreEqual(result, 0.003752, 0.001, "Ошибка конвертации"); }