LoginSignup
0
0

More than 5 years have passed since last update.

NUnitFormsでModalWindow のテストが null exceptionで動かなくてはまったので動いた時の記述メモ。

Last updated at Posted at 2013-12-13
using NUnit.Extensions.Forms;

/// <summary>
/// 時間の逆転時のwarningチェック
/// </summary>
[Test]
public void ClickOKWhenBeginTimeIsNewerThanEndTimeThenWarningDialogIsShown()
{
    using(var f = new AForm())
    {
        f.Show();
        f.SetEnd(DateTime.Now);
        f.SetBegin(DateTime.Now.AddDays(1));
        using (ModalFormTester modalTester = new ModalFormTester())
        {
            modalTester.FormHandler = (s, wnd, form) =>
            {
                MessageBoxTester messageBox = new MessageBoxTester(wnd);
                Assert.That(messageBox.Text, Is.EqualTo("Begin time is newer than end time."));
                Assert.That(messageBox.Title, Is.EqualTo("Caution"));
                messageBox.ClickOk();
            };
            var btn = new ButtonTester("OkButton");
            btn.Properties.Enabled = true;
            btn.Click();
        }
    }
}

NUnitForms は svn checkout して、自分で build する。
それを参照して使用する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0