Skip to content

Commit ae6fe72

Browse files
[dotnet] Migrate NUnit assertions to Assert.That syntax (#14853)
1 parent 313f7a5 commit ae6fe72

File tree

65 files changed

+919
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+919
-842
lines changed

dotnet/test/common/AlertsTest.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void ShouldAllowUsersToAcceptAnAlertManually()
4848
alert.Accept();
4949

5050
// If we can perform any action, we're good to go
51-
Assert.AreEqual("Testing Alerts", driver.Title);
51+
Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
5252
}
5353

5454
[Test]
@@ -81,7 +81,7 @@ public void ShouldAllowUsersToAcceptAnAlertWithNoTextManually()
8181
alert.Accept();
8282

8383
// If we can perform any action, we're good to go
84-
Assert.AreEqual("Testing Alerts", driver.Title);
84+
Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
8585
}
8686

8787
[Test]
@@ -95,7 +95,7 @@ public void ShouldAllowUsersToDismissAnAlertManually()
9595
alert.Dismiss();
9696

9797
// If we can perform any action, we're good to go
98-
Assert.AreEqual("Testing Alerts", driver.Title);
98+
Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
9999
}
100100

101101
[Test]
@@ -109,7 +109,7 @@ public void ShouldAllowAUserToAcceptAPrompt()
109109
alert.Accept();
110110

111111
// If we can perform any action, we're good to go
112-
Assert.AreEqual("Testing Prompt", driver.Title);
112+
Assert.That(driver.Title, Is.EqualTo("Testing Prompt"));
113113
}
114114

115115
[Test]
@@ -123,7 +123,7 @@ public void ShouldAllowAUserToDismissAPrompt()
123123
alert.Dismiss();
124124

125125
// If we can perform any action, we're good to go
126-
Assert.AreEqual("Testing Prompt", driver.Title);
126+
Assert.That(driver.Title, Is.EqualTo("Testing Prompt"));
127127
}
128128

129129
[Test]
@@ -138,7 +138,7 @@ public void ShouldAllowAUserToSetTheValueOfAPrompt()
138138
alert.Accept();
139139

140140
string result = driver.FindElement(By.Id("text")).Text;
141-
Assert.AreEqual("cheese", result);
141+
Assert.That(result, Is.EqualTo("cheese"));
142142
}
143143

144144
[Test]
@@ -173,7 +173,7 @@ public void ShouldAllowTheUserToGetTheTextOfAnAlert()
173173
string value = alert.Text;
174174
alert.Accept();
175175

176-
Assert.AreEqual("cheese", value);
176+
Assert.That(value, Is.EqualTo("cheese"));
177177
}
178178

179179
[Test]
@@ -187,7 +187,7 @@ public void ShouldAllowTheUserToGetTheTextOfAPrompt()
187187
string value = alert.Text;
188188
alert.Accept();
189189

190-
Assert.AreEqual("Enter something", value);
190+
Assert.That(value, Is.EqualTo("Enter something"));
191191
}
192192

193193
[Test]
@@ -222,7 +222,7 @@ public void ShouldAllowUsersToAcceptAnAlertInAFrame()
222222
alert.Accept();
223223

224224
// If we can perform any action, we're good to go
225-
Assert.AreEqual("Testing Alerts", driver.Title);
225+
Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
226226
}
227227

228228
[Test]
@@ -244,7 +244,7 @@ public void ShouldAllowUsersToAcceptAnAlertInANestedFrame()
244244
alert.Accept();
245245

246246
// If we can perform any action, we're good to go
247-
Assert.AreEqual("Testing Alerts", driver.Title);
247+
Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
248248
}
249249

250250
[Test]
@@ -298,7 +298,7 @@ public void PromptShouldUseDefaultValueIfNoKeysSent()
298298

299299
IWebElement element = driver.FindElement(By.Id("text"));
300300
WaitFor(ElementTextToEqual(element, "This is a default value"), "Element text was not 'This is a default value'");
301-
Assert.AreEqual("This is a default value", element.Text);
301+
Assert.That(element.Text, Is.EqualTo("This is a default value"));
302302
}
303303

304304
[Test]
@@ -311,7 +311,7 @@ public void PromptShouldHaveNullValueIfDismissed()
311311
alert.Dismiss();
312312
IWebElement element = driver.FindElement(By.Id("text"));
313313
WaitFor(ElementTextToEqual(element, "null"), "Element text was not 'null'");
314-
Assert.AreEqual("null", element.Text);
314+
Assert.That(element.Text, Is.EqualTo("null"));
315315
}
316316

317317
[Test]
@@ -349,10 +349,10 @@ function displayTwoPrompts() {
349349

350350
IWebElement element1 = driver.FindElement(By.Id("text1"));
351351
WaitFor(ElementTextToEqual(element1, "brie"), "Element text was not 'brie'");
352-
Assert.AreEqual("brie", element1.Text);
352+
Assert.That(element1.Text, Is.EqualTo("brie"));
353353
IWebElement element2 = driver.FindElement(By.Id("text2"));
354354
WaitFor(ElementTextToEqual(element2, "cheddar"), "Element text was not 'cheddar'");
355-
Assert.AreEqual("cheddar", element2.Text);
355+
Assert.That(element2.Text, Is.EqualTo("cheddar"));
356356
}
357357

358358
[Test]
@@ -370,7 +370,7 @@ public void ShouldHandleAlertOnPageLoad()
370370
string value = alert.Text;
371371
alert.Accept();
372372

373-
Assert.AreEqual("onload", value);
373+
Assert.That(value, Is.EqualTo("onload"));
374374
IWebElement element = driver.FindElement(By.TagName("p"));
375375
WaitFor(ElementTextToEqual(element, "Page with onload event handler"), "Element text was not 'Page with onload event handler'");
376376
}
@@ -387,7 +387,7 @@ public void ShouldHandleAlertOnPageLoadUsingGet()
387387
string value = alert.Text;
388388
alert.Accept();
389389

390-
Assert.AreEqual("onload", value);
390+
Assert.That(value, Is.EqualTo("onload"));
391391
WaitFor(ElementTextToEqual(driver.FindElement(By.TagName("p")), "Page with onload event handler"), "Could not find element with text 'Page with onload event handler'");
392392
}
393393

@@ -412,7 +412,7 @@ public void ShouldNotHandleAlertInAnotherWindow()
412412
driver.FindElement(By.Id("open-new-window")).Click();
413413
List<String> allWindows = new List<string>(driver.WindowHandles);
414414
allWindows.Remove(mainWindow);
415-
Assert.AreEqual(1, allWindows.Count);
415+
Assert.That(allWindows, Has.One.Items);
416416
onloadWindow = allWindows[0];
417417

418418
Assert.That(() =>
@@ -472,8 +472,8 @@ public void ShouldHandleAlertOnFormSubmit()
472472
string text = alert.Text;
473473
alert.Accept();
474474

475-
Assert.AreEqual("Tasty cheese", text);
476-
Assert.AreEqual("Testing Alerts", driver.Title);
475+
Assert.That(text, Is.EqualTo("Tasty cheese"));
476+
Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
477477
}
478478

479479
private IAlert AlertToBePresent()

0 commit comments

Comments
 (0)