/// <summary> /// Обработка изменения значения зеленого цвета /// </summary> /// <param name="sender">Отправитель</param> /// <param name="e">Параметры</param> private void green_TextChanged(object sender, EventArgs e) { try { logic.onChangeGreenPart(sender); } catch (Exception exc) { } }
public void onChangeColorTest() { BMPLogic logic = new BMPLogic(200, 200); TextBox textBox = new TextBox(); textBox.Text = "43"; logic.onChangeRedPart(textBox); Assert.Equal(43, logic.getPen().Color.R); textBox.Text = "27"; logic.onChangeGreenPart(textBox); Assert.Equal(27, logic.getPen().Color.G); textBox.Text = "32"; logic.onChangeBluePart(textBox); Assert.Equal(32, logic.getPen().Color.B); textBox.Text = "344"; logic.onChangeRedPart(textBox); Assert.Equal(255, logic.getPen().Color.R); textBox.Text = "2337"; logic.onChangeGreenPart(textBox); Assert.Equal(255, logic.getPen().Color.G); textBox.Text = "332"; logic.onChangeBluePart(textBox); Assert.Equal(255, logic.getPen().Color.B); textBox.Text = "-5"; logic.onChangeRedPart(textBox); Assert.Equal(0, logic.getPen().Color.R); textBox.Text = "-12"; logic.onChangeGreenPart(textBox); Assert.Equal(0, logic.getPen().Color.G); textBox.Text = "-333"; logic.onChangeBluePart(textBox); Assert.Equal(0, logic.getPen().Color.B); textBox.Text = "abc"; logic.onChangeGreenPart(textBox); logic.onChangeRedPart(textBox); logic.onChangeBluePart(textBox); Assert.Equal(Color.FromArgb(255, 0, 0, 0), logic.getPen().Color); }