Anybody know how to test Message Box, it`s appearance? While i wrote this code:
[TestMethod]
public void TestDisplayError()
{
Application application = Application.Launch("D:\\VS projects\\2Lab\\2Lab\\bin\\Debug\\netcoreapp3.1\\2Lab.exe");
Window window = application.GetWindows().First();
TextBox t1 = window.Items[5] as TextBox;
TextBox t2 = window.Items[4] as TextBox;
List<Button> buttons = CreateButtonList(window);
t1.Text = "5";
t2.Text = "0";
DevideButtonClick(buttons);
}
The point is when i try divide by zero, message box must appearance.
CodePudding user response:
Okey i changed my mind. Here is solution
CodePudding user response:
[TestMethod]
public void TestDisplayError()
{
Application application = Application.Launch("D:\\VS projects\\2Lab\\2Lab\\bin\\Debug\\netcoreapp3.1\\2Lab.exe");
Window window = application.GetWindows().First();
Assert.IsNotNull(window);
TextBox t1 = window.Items[5] as TextBox;
TextBox t2 = window.Items[4] as TextBox;
List<Button> buttons = CreateButtonList(window);
t1.Text = "5";
t2.Text = "0";
DevideButtonClick(buttons);
var messageBox = window.MessageBox("");
Assert.IsNotNull(messageBox);
}