下面是一個簡單的WPF應用程序代碼的一部分:3個文本框,一個dropdownList和一個按鈕。通過點擊一個按鈕,將會檢查輸入值。WPF應用程序的單元測試
private void Button_Click_1(object sender, RoutedEventArgs e)
{
if (textBox1.Text.Length>127)
throw new ArgumentException();
if (string.IsNullOrEmpty(textBox2.Text))
errorsList.Add("You must to fill out textbox2");
else if (string.IsNullOrEmpty(textBox3.Text))
errorsList.Add("You must to fill out textbox3");
else if
{
Regex regex = new Regex(@".........");
Match match = regex.Match(emailTxt.Text);
if (!match.Success)
errorsList.Add("e-mail is inlvalid");
}
//.....
}
我必須使用任何單元測試框架來測試它。我想知道是否有可能在這裏做單元測試?我想這不是,對吧?