-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathMessageBoxTests.cs
More file actions
54 lines (50 loc) · 1.8 KB
/
MessageBoxTests.cs
File metadata and controls
54 lines (50 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using NUnit.Framework;
using TestStack.White.Configuration;
using TestStack.White.UIItems;
using TestStack.White.UIItems.Finders;
namespace TestStack.White.UITests
{
[TestFixture(WindowsFramework.WinForms)]
[TestFixture(WindowsFramework.Wpf)]
public class MessageBoxTests : WhiteUITestBase
{
public MessageBoxTests(WindowsFramework framework)
: base(framework)
{
}
[Test]
public void IsClosedTest()
{
MainWindow.Get<Button>("OpenMessageBox").Click();
var messageBox = MainWindow.MessageBox("Test message box");
Assert.That(messageBox.IsClosed, Is.False);
messageBox.Close();
Assert.That(messageBox.IsClosed, Is.True);
}
[Test]
public void CloseMessageBoxTest()
{
MainWindow.Get<Button>("OpenMessageBox").Click();
var messageBox = MainWindow.MessageBox("Test message box");
var label = MainWindow.Get<Label>("65535");
Assert.That(label.Text, Is.EqualTo("Close me"));
messageBox.Close();
}
[Test]
public void ClickButtonOnMessageBoxTest()
{
MainWindow.Get<Button>("OpenMessageBox").Click();
var messageBox = MainWindow.MessageBox("Test message box");
messageBox.Get<Button>(SearchCriteria.ByAutomationId("2")).Click();
}
[Test]
public void ThrowsWhenNotFoundTest()
{
using (CoreAppXmlConfiguration.Instance.ApplyTemporarySetting(c => c.FindWindowTimeout = 500))
{
Assert.That(() => { MainWindow.MessageBox("foo"); },
Throws.TypeOf<AutomationException>().With.Message.EqualTo("Could not find modal window with title: foo"));
}
}
}
}