/ Published in: C#
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; public FormTests() { } [Test] public void FormCreate() { LaunchForm1(); Assert.AreEqual("Test Form", testForm.Text); } [Test] public void ButtonMessageBoxClick() { LaunchForm1(); nextExpectedModal = "Test Message Box"; ExpectModal(nextExpectedModal, "OnModal_DismissMessageBox"); bt.Click(); nextExpectedModal = string.Empty; } [Test] public void ButtonChangeTextClick() { LaunchForm1(); bt.Click(); Assert.AreEqual("New Value",tbt.Text); } [Test] public void LabelTest() { LaunchForm1(); Assert.AreEqual("Test Field:", lt.Text); } public void LaunchForm1() { testForm.Show(); } private void OnModal_DismissMessageBox() { System.Threading.Thread.Sleep(rnd.Next(3000)); mbt.ClickOk(); } public override bool UseHidden { get { return useHidden; } } } }