且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何开始Windows窗体的单元测试?

更新时间:2023-12-06 13:07:58

);
if String .IsNullOrEmpty(txtlname.Text)) // 检查文本框是否为空
{
toolStripStatusLabel1.Text = 姓氏必填;
}
else if (pattern.IsMatch(txtlname.Text)) // 正则表达式模式匹配在这里完成
{
lastname = txtlname.Text.ToUpper()。Trim(); // 修剪前后空格
fetchPatientDetails(lastname);
}
else
{
toolStripStatusLabel1.Text = 输入无效;
}
}
"); if (String.IsNullOrEmpty(txtlname.Text)) //Checks if the textbox is empty or not { toolStripStatusLabel1.Text= "Last name Required"; } else if (pattern.IsMatch(txtlname.Text)) //Regex pattern matching is done here { lastname = txtlname.Text.ToUpper().Trim(); //Trims the before and after spaces fetchPatientDetails(lastname); } else { toolStripStatusLabel1.Text = "Invalid Input"; } }










private void GridOperations(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex = e.RowIndex;
            DataGridViewRow row = ((DataGridView)sender).Rows[rowindex];
            string id = row.Cells[0].Value.ToString();
            switch (((DataGridView)sender).Name)
            {
                case "dgvpatient":
                    hidereaction();
                    hideallergy();
                    lblencounter.Show();
                    string patientid = row.Cells[0].Value.ToString();
                    displayDetails(sender, id, 1, 2180508);
                    break;

                case "dgvencounter":
                    hidereaction();
                    lblallergy.Show();
                    displayDetails(sender, id, 2, 2180509);
                    break;

                case "dgvallergy":
                    lblreaction.Show();
                    displayDetails(sender, id, 3, 2180510);
                    break;
            }
        }





我的尝试:



我不知道如何继续。

因此我没有尝试任何东西



What I have tried:

I have no idea how to proceed.
Hence i have not tried anything


为您的c#代码创建单元测试 [ ^ ]