NUnit问题 [英] NUnit Question
本文介绍了NUnit问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好专家
我正在从事c#项目,需要进行NUnit测试.如果这不是NUnit的正确论坛,请接受我的歉意.
I am working on c# project and need to do NUnit testing . Please accept my apologies if this is not the correct forum for NUnit.
问题是我正在尝试使用NUnitForms进行GUI测试.我需要测试FileDialog,这是代码:
The problem is I am trying to use NUnitForms for GUI testing. I neeed to test FileDialog and here is the code:
[Function to test]
private void btnBrowse_Click(object sender, EventArgs e)
{
#region Browse for a file where number of machines are avaialable
ItextBox.Text = "";
// Displays an OpenFileDialog so the user can select a text file.
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Text Files|*.txt";
openFileDialog1.Title = "Select a text File";
//DialogResult result = openFileDialog1.ShowDialog();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
ItextBox.Text = openFileDialog1.FileName;
}
#endregion
}
Here is the test class function:
private Form1 _form;
///<summary>
/// Sets up this test by showing a new OpenFileDialogTestForm form.
///</summary>
public override void Setup()
{
base.Setup();
_form = new Form1();
_form.Show();
}
[Test]
public void TypingNotAllowed()
{
//base.init();
//Form1 form = new Form1();
ExpectFileDialog("browserHandler");
ButtonTester button = new ButtonTester("btnBrowse");
button.Click();
//button.FireEvent("Click");
}
public void browserHandler()
{
OpenFileDialogTester dlg_tester = new OpenFileDialogTester("folderBrowserDialog1");
string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "abc.txt");
dlg_tester.OpenFile(fileName);
}
目的是打开文件对话框并通过测试,但这没有用.请让我知道我在这里想念什么?
The aim is to open file dialog and pass the test but it doesnt work . Please let me know what am I missing here ?
谢谢
Varun
推荐答案
有任何提示吗?
any hints plz?
这篇关于NUnit问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文