|
/*
* This file is licensed under the Code Project CPOL License
* http://www.codeproject.com/info/cpol10.aspx
*
* © Steffen Schütte 2008
*/
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using de.steffenschuette.UITest.Framework;
using System.Threading;
using System.Windows.Forms;
namespace de.steffenschuette.UITest.DemoApp.UITest
{
[TestFixture]
public class TestFixture1
{
private UITestBench myTestBench;
[SetUp]
public void SetUp()
{
Console.WriteLine("Setup ThreadId: " + Thread.CurrentThread.ManagedThreadId);
myTestBench = new UITestBench();
myTestBench.StartApplication("UITestDemoApp", null);
//Some some to start the demo app
Thread.Sleep(2000);
}
[TearDown]
public void TearDown()
{
myTestBench.TerminateApplication();
}
[Test(Description="TestCase 1")]
public void TestCase1()
{
Console.WriteLine("TC1 ThreadId: " + Thread.CurrentThread.ManagedThreadId);
myTestBench.PerformClick("Form1", "File/Open text file 1...");
SendKeys.SendWait("file1.txt");
SendKeys.SendWait("{ENTER}");
Thread.Sleep(2000);
myTestBench.PerformClick("Form1", "File/Open text file 2...");
SendKeys.SendWait("file2.txt");
SendKeys.SendWait("{ENTER}");
Thread.Sleep(2000);
myTestBench.PerformClick("Form1", "toolStrip1/Merge");
Thread.Sleep(2000);
myTestBench.SetText("MergeDlg", "MergeDlg/Demo Textbox", "Text has been set");
Thread.Sleep(2000);
myTestBench.PerformClick("MergeDlg", "MergeDlg/MixFilesBtn");
Thread.Sleep(4000);
myTestBench.SetSelectedIndex("MergeDlg", "MergeDlg/ListBox[2]", 1);
Thread.Sleep(4000);
myTestBench.PerformClick("MergeDlg", "MergeDlg/OK");
Thread.Sleep(2000);
myTestBench.PerformClick("Form1", "File/Exit");
}
[Test(Description = "TestCase 2")]
public void TestCase2()
{
Console.WriteLine("TC2: ThreadId" + Thread.CurrentThread.ManagedThreadId);
myTestBench.PerformClick("Form1", "File/Open text file 1...");
SendKeys.SendWait("file1.txt");
SendKeys.SendWait("{ENTER}");
Thread.Sleep(2000);
myTestBench.PerformClick("Form1", "toolStrip1/Merge");
Thread.Sleep(2000);
myTestBench.PerformClick("MergeDlg", "MergeDlg/MixFilesBtn");
Thread.Sleep(2000);
//No more testing as this use case forced an error in the aplication under test
//to show that this does not crash the unit test
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.