Revision: 2737
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 10, 2007 16:32 by rengber
Initial Code
using System; using NUnit.Framework; using NUnit.Extensions.Forms; namespace NUnitFormsTests { /// <summary> /// Summary description for Class1. /// </summary> [TestFixture] public class FormTests : NUnit.Extensions.Forms.NUnitFormsAssertTest { private string nextExpectedModal = ""; private bool useHidden = true; private TargetForm.Form1 testForm = null; private System.Random rnd = new Random(); public FormTests() { } [Test] public void FormCreate() { LaunchForm1(); Assert.AreEqual("Test Form", testForm.Text); } [Test] public void ButtonMessageBoxClick() { LaunchForm1(); ButtonTester bt = new ButtonTester("btnTest", testForm); nextExpectedModal = "Test Message Box"; ExpectModal(nextExpectedModal, "OnModal_DismissMessageBox"); bt.Click(); nextExpectedModal = string.Empty; } [Test] public void ButtonChangeTextClick() { LaunchForm1(); ButtonTester bt = new ButtonTester("btnChangeText", testForm); bt.Click(); NUnit.Extensions.Forms.TextBoxTester tbt = new TextBoxTester("txtTestField", testForm); Assert.AreEqual("New Value",tbt.Text); } [Test] public void LabelTest() { LaunchForm1(); NUnit.Extensions.Forms.LabelTester lt = new LabelTester("lblTestField", testForm); Assert.AreEqual("Test Field:", lt.Text); } public void LaunchForm1() { testForm = new TargetForm.Form1(); testForm.Show(); } private void OnModal_DismissMessageBox() { System.Threading.Thread.Sleep(rnd.Next(3000)); NUnit.Extensions.Forms.MessageBoxTester mbt = new MessageBoxTester(nextExpectedModal); mbt.ClickOk(); } public override bool UseHidden { get { return useHidden; } } } }
Initial URL
Initial Description
Note: The override of UseHidden controls whether or not NUnit will create forms in a hidden desktop/winstation. It needs to be set before the constructor is called in order to be effective.
Initial Title
Using NUnitForms
Initial Tags
Initial Language
C#