【C#】【NUnit】 NUnitForms ~ サンプル編 ~

■ Button

サンプル

ButtonTester buttonTester = new ButtonTester("button1"); // 定義
buttonTester.Click(); // クリック


■ TextBox

サンプル

TextBoxTester textTester = new TextBoxTester("textBox1"); // 定義

Assert.AreEqual(255, textTester["MaxLength"]); // MaxLength [1]
Assert.AreEqual(255, textTester.Properties.MaxLength); // MaxLength [2]

Assert.AreEqual(string.Empty, textTester.Text); // TextBoxの中身を比較

textTester.Enter("aaaa"); // TextBoxに文字入力
Assert.AreEqual("aaaa", textTester.Text); // TextBoxの中身を比較

参考資料

http://nunitforms.sourceforge.net/MSDN/index.html
http://www.atmarkit.co.jp/fdotnet/nagile/nagile03/nagile03_02.html

■ RadioButton

サンプル

RadioButtonTester radioButtonTester1 = new RadioButtonTester("groupBox1.radioButton1"); // 定義
RadioButtonTester radioButtonTester2 = new RadioButtonTester("groupBox1.radioButton2"); // 定義

Assert.IsTrue(radioButtonTester1.Checked); // Checkされているかを確認
Assert.IsFalse(radioButtonTester2.Checked); // Checkされていないかを確認

■ CheckBox

サンプル

CheckBoxTester checkBox1Tester = new CheckBoxTester("checkBox1");

Assert.IsTrue(checkBox1Tester.Properties.Enabled);
Assert.IsFalse(checkBox1Tester.Checked);
checkBox1Tester.Click();
Assert.IsTrue(checkBox1Tester.Checked);

関連記事

NUnitForms ~ Hello World編 ~

https://blogs.yahoo.co.jp/dk521123/21001385.html

NUnitForms ~ あれこれ編 ~

https://blogs.yahoo.co.jp/dk521123/21717521.html