如何进行C#单元测试,急
请各位高手帮忙看看,如何进行C#单元测试?万分感谢~!namespace 成绩管理系统
{
public partial class Form1 : Form
{
Boolean b = false;
string str1 = @"Data Source=.;Initial Catalog=StudentCj;Integrated Security=True"; //无密码建立连接SQL数据库对象
public Form1()
{
InitializeComponent();
this.skinEngine1.SkinFile = "MP10.ssk";//皮肤
}
private void Form1_Load(object sender, EventArgs e)//窗体加载时清空文本中的值
{
textBox1.Text = "";
textBox2.Text = "";
}
private voidselect()
{
SqlConnection con = new SqlConnection(str1);
string sql = "select Name,passwd from Admin where Name='" + textBox1.Text + "' ";
SqlCommand com = new SqlCommand();
com.CommandText = sql;
com.Connection = con;
con.Open();
SqlDataReader ada = com.ExecuteReader();
if (ada.Read())
{
if (ada["passwd"].ToString().Trim() != textBox2.Text.Trim())
{
MessageBox.Show("密码不正确");
textBox2.Focus();
return;
}
else
{
con.Close();
b = true;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
select();
if (b)
{
Main lons1 = new Main();
lons1.Show();
this.Visible = false; //进入Main窗体时不显示Form1窗体
}
else
{
MessageBox.Show("用户名和密码不正确 ");
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close(); //关闭
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
} /// <summary>
///A test for pictureBox1_Click
///</summary>
public void pictureBox1_ClickTest()
{
Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value
object sender = null; // TODO: Initialize to an appropriate value
EventArgs e = null; // TODO: Initialize to an appropriate value
target.pictureBox1_Click(sender, e);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
/// <summary>
///A test for Form1_Load
///</summary>
public void Form1_LoadTest()
{
Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value
object sender = null; // TODO: Initialize to an appropriate value
EventArgs e = null; // TODO: Initialize to an appropriate value
target.Form1_Load(sender, e);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
/// <summary>
///A test for button2_Click
///</summary>
public void button2_ClickTest()
{
Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value
object sender = null; // TODO: Initialize to an appropriate value
EventArgs e = null; // TODO: Initialize to an appropriate value
target.button2_Click(sender, e);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
/// <summary>
///A test for button1_Click
///</summary>
public void button1_ClickTest()
{
Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value
object sender = null; // TODO: Initialize to an appropriate value
EventArgs e = null; // TODO: Initialize to an appropriate value
target.button1_Click(sender, e);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
/// <summary>
///A test for select
///</summary>
public void selectTest()
{
Form1_Accessor target = new Form1_Accessor(); // TODO: Initialize to an appropriate value
target.select();
Assert.Inconclusive("A method that does not return a value cannot be verified.");
} cool! Smart answer
页:
[1]