Skip to content

Commit

Permalink
[dotnet] Migrate NUnit assertions to Assert.That syntax (#14853)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenderMichael authored Dec 6, 2024
1 parent 313f7a5 commit ae6fe72
Show file tree
Hide file tree
Showing 65 changed files with 919 additions and 842 deletions.
38 changes: 19 additions & 19 deletions dotnet/test/common/AlertsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void ShouldAllowUsersToAcceptAnAlertManually()
alert.Accept();

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

[Test]
Expand Down Expand Up @@ -81,7 +81,7 @@ public void ShouldAllowUsersToAcceptAnAlertWithNoTextManually()
alert.Accept();

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

[Test]
Expand All @@ -95,7 +95,7 @@ public void ShouldAllowUsersToDismissAnAlertManually()
alert.Dismiss();

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

[Test]
Expand All @@ -109,7 +109,7 @@ public void ShouldAllowAUserToAcceptAPrompt()
alert.Accept();

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

[Test]
Expand All @@ -123,7 +123,7 @@ public void ShouldAllowAUserToDismissAPrompt()
alert.Dismiss();

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

[Test]
Expand All @@ -138,7 +138,7 @@ public void ShouldAllowAUserToSetTheValueOfAPrompt()
alert.Accept();

string result = driver.FindElement(By.Id("text")).Text;
Assert.AreEqual("cheese", result);
Assert.That(result, Is.EqualTo("cheese"));
}

[Test]
Expand Down Expand Up @@ -173,7 +173,7 @@ public void ShouldAllowTheUserToGetTheTextOfAnAlert()
string value = alert.Text;
alert.Accept();

Assert.AreEqual("cheese", value);
Assert.That(value, Is.EqualTo("cheese"));
}

[Test]
Expand All @@ -187,7 +187,7 @@ public void ShouldAllowTheUserToGetTheTextOfAPrompt()
string value = alert.Text;
alert.Accept();

Assert.AreEqual("Enter something", value);
Assert.That(value, Is.EqualTo("Enter something"));
}

[Test]
Expand Down Expand Up @@ -222,7 +222,7 @@ public void ShouldAllowUsersToAcceptAnAlertInAFrame()
alert.Accept();

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

[Test]
Expand All @@ -244,7 +244,7 @@ public void ShouldAllowUsersToAcceptAnAlertInANestedFrame()
alert.Accept();

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

[Test]
Expand Down Expand Up @@ -298,7 +298,7 @@ public void PromptShouldUseDefaultValueIfNoKeysSent()

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

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

[Test]
Expand Down Expand Up @@ -349,10 +349,10 @@ function displayTwoPrompts() {

IWebElement element1 = driver.FindElement(By.Id("text1"));
WaitFor(ElementTextToEqual(element1, "brie"), "Element text was not 'brie'");
Assert.AreEqual("brie", element1.Text);
Assert.That(element1.Text, Is.EqualTo("brie"));
IWebElement element2 = driver.FindElement(By.Id("text2"));
WaitFor(ElementTextToEqual(element2, "cheddar"), "Element text was not 'cheddar'");
Assert.AreEqual("cheddar", element2.Text);
Assert.That(element2.Text, Is.EqualTo("cheddar"));
}

[Test]
Expand All @@ -370,7 +370,7 @@ public void ShouldHandleAlertOnPageLoad()
string value = alert.Text;
alert.Accept();

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

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

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

Assert.That(() =>
Expand Down Expand Up @@ -472,8 +472,8 @@ public void ShouldHandleAlertOnFormSubmit()
string text = alert.Text;
alert.Accept();

Assert.AreEqual("Tasty cheese", text);
Assert.AreEqual("Testing Alerts", driver.Title);
Assert.That(text, Is.EqualTo("Tasty cheese"));
Assert.That(driver.Title, Is.EqualTo("Testing Alerts"));
}

private IAlert AlertToBePresent()
Expand Down
Loading

0 comments on commit ae6fe72

Please sign in to comment.