-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathButtonTests.cs
More file actions
45 lines (41 loc) · 1.51 KB
/
ButtonTests.cs
File metadata and controls
45 lines (41 loc) · 1.51 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
using System;
using System.Windows.Automation;
using NUnit.Framework;
using TestStack.White.Configuration;
using TestStack.White.UIItems;
using TestStack.White.UIItems.Finders;
namespace TestStack.White.UITests.ControlTests
{
[TestFixture(WindowsFramework.WinForms)]
[TestFixture(WindowsFramework.Wpf)]
public class ButtonTests : WhiteUITestBase
{
public ButtonTests(WindowsFramework framework)
: base(framework) { }
[Test]
public void Click()
{
var button = MainWindow.Get<Button>("ButtonWithTooltip");
button.Click();
Assert.That(button.Text, Is.EqualTo("Button Clicked with Mouse"));
}
[Test]
public void ThrowsWhenNotFound()
{
using (CoreConfigurationLocator.Get().ApplyTemporarySettings(c => c.FindWindowTimeout = 500))
{
Assert.That(() => { MainWindow.Get<Button>(SearchCriteria.ByAutomationId("foo")); },
Throws.TypeOf<AutomationException>().With.
Message.EqualTo(String.Format("Failed to get (ControlType={0} or ControlType={1}),AutomationId=foo",
ControlType.Button.LocalizedControlType, ControlType.CheckBox.LocalizedControlType)));
}
}
[Test]
public void TestInvokePattern()
{
var button = MainWindow.Get<Button>("ButtonWithTooltip");
button.Invoke();
Assert.That(button.Text, Is.EqualTo("Clicked"));
}
}
}