diff --git a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj index 2e0677d5..bcc16bd4 100644 --- a/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj +++ b/Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj @@ -82,8 +82,9 @@ - - + + + diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj index ba28e051..d67d24fd 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 false @@ -29,7 +29,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs index 9f2064b1..b9ce3fbd 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/JsActionsTests.cs @@ -19,7 +19,7 @@ public void Should_BePossibleTo_Click() var welcomeForm = new WelcomeForm(); welcomeForm.Open(); welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.Click(); - Assert.IsTrue(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); + Assert.That(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); } [Test] @@ -28,7 +28,7 @@ public void Should_BePossibleTo_ClickAndWait() var welcomeForm = new WelcomeForm(); welcomeForm.Open(); welcomeForm.GetExampleLink(AvailableExample.Dropdown).JsActions.ClickAndWait(); - Assert.IsTrue(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); + Assert.That(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); } [Test] @@ -39,7 +39,7 @@ public void Should_BePossibleTo_HighlightElement() var dropdownExample = welcomeForm.GetExampleLink(AvailableExample.Dropdown); dropdownExample.JsActions.HighlightElement(HighlightState.Highlight); var border = dropdownExample.GetCssValue("border"); - Assert.AreEqual("3px solid rgb(255, 0, 0)", border, "Element should be highlighted"); + Assert.That(border, Is.EqualTo("3px solid rgb(255, 0, 0)"), "Element should be highlighted"); } [Test] @@ -48,7 +48,7 @@ public void Should_BePossibleTo_HoverMouse() var menuForm = new JQueryMenuForm(); menuForm.Open(); JQueryMenuForm.EnabledButton.JsActions.HoverMouse(); - Assert.IsTrue(JQueryMenuForm.IsEnabledButtonFocused, "Element should be focused after hover"); + Assert.That(JQueryMenuForm.IsEnabledButtonFocused, "Element should be focused after hover"); } [Test] @@ -64,7 +64,7 @@ public void Should_BePossibleTo_SetFocus() ForgotPasswordForm.EmailTextBox.JsActions.SetFocus(); ForgotPasswordForm.EmailTextBox.SendKeys(Keys.Delete); ForgotPasswordForm.EmailTextBox.SendKeys(Keys.Backspace); - Assert.AreEqual(expectedText, ForgotPasswordForm.EmailTextBox.Value, $"One character should be removed from '{currentText}'"); + Assert.That(ForgotPasswordForm.EmailTextBox.Value, Is.EqualTo(expectedText), $"One character should be removed from '{currentText}'"); } [Test] @@ -74,9 +74,9 @@ public void Should_BePossibleTo_CheckIsElementOnScreen() hoversForm.Open(); Assert.Multiple(() => { - Assert.IsFalse(HoversForm.GetHiddenElement(HoverExample.First, ElementState.ExistsInAnyState).JsActions.IsElementOnScreen(), + Assert.That(HoversForm.GetHiddenElement(HoverExample.First, ElementState.ExistsInAnyState).JsActions.IsElementOnScreen(), Is.False, $"Hidden element for {HoverExample.First} should be invisible."); - Assert.IsTrue(HoversForm.GetExample(HoverExample.First).JsActions.IsElementOnScreen(), + Assert.That(HoversForm.GetExample(HoverExample.First).JsActions.IsElementOnScreen(), $"Element for {HoverExample.First} should be visible."); }); } @@ -89,7 +89,7 @@ public void Should_BePossibleTo_SetValue() const string text = "text"; keyPressesForm.InputTextBox.JsActions.SetValue(text); var actualText = keyPressesForm.InputTextBox.Value; - Assert.AreEqual(text, actualText, $"Text should be '{text}' after setting value via JS"); + Assert.That(actualText, Is.EqualTo(text), $"Text should be '{text}' after setting value via JS"); } [Test] @@ -97,7 +97,7 @@ public void Should_BePossibleTo_GetElementText() { var welcomeForm = new WelcomeForm(); welcomeForm.Open(); - Assert.AreEqual(WelcomeForm.SubTitle, welcomeForm.SubTitleLabel.JsActions.GetElementText(), + Assert.That(welcomeForm.SubTitleLabel.JsActions.GetElementText(), Is.EqualTo(WelcomeForm.SubTitle), $"Sub title should be {WelcomeForm.SubTitle}"); } @@ -108,7 +108,7 @@ public void Should_BePossibleTo_GetXPathLocator() welcomeForm.Open(); var actualLocator = welcomeForm.SubTitleLabel.JsActions.GetXPath(); const string expectedLocator = "/html/body/DIV[2]/DIV[1]/H2[1]"; - Assert.AreEqual(expectedLocator, actualLocator, $"Locator of sub title should be {expectedLocator}"); + Assert.That(actualLocator, Is.EqualTo(expectedLocator), $"Locator of sub title should be {expectedLocator}"); } [Test] @@ -117,7 +117,7 @@ public void Should_BePossibleTo_GetViewPortCoordinates() var welcomeForm = new WelcomeForm(); welcomeForm.Open(); var actualPoint = welcomeForm.SubTitleLabel.JsActions.GetViewPortCoordinates(); - Assert.IsFalse(actualPoint.IsEmpty, "Coordinates of Sub title should not be empty"); + Assert.That(actualPoint.IsEmpty, Is.False, "Coordinates of Sub title should not be empty"); } [Test] @@ -148,7 +148,7 @@ public void Should_BePossibleTo_ScrollBy() Select(item => (int)Math.Round(double.Parse(item.ToString()))) .ToList(); var actualPoint = new Point(currentCoordinates[0], currentCoordinates[1]); - Assert.AreEqual(point, actualPoint, $"Current coordinates should be '{point}'"); + Assert.That(actualPoint, Is.EqualTo(point), $"Current coordinates should be '{point}'"); } [Test] @@ -163,7 +163,7 @@ public void Should_BePossibleTo_ScrollToTheCenter() var currentY = AqualityServices.Browser.ExecuteScriptFromFile("Resources.GetElementYCoordinate.js", welcomeForm.GetExampleLink(AvailableExample.Hovers).GetElement()).ToString(); var coordinateRelatingWindowCenter = double.Parse(windowSize) / 2 - double.Parse(currentY); - Assert.LessOrEqual(Math.Abs(coordinateRelatingWindowCenter), accuracy, "Upper bound of element should be in the center of the page"); + Assert.That(Math.Abs(coordinateRelatingWindowCenter), Is.LessThanOrEqualTo(accuracy), "Upper bound of element should be in the center of the page"); } [Test] diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs index ebdc1d3e..2bd2736b 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Actions/MouseActionsTests.cs @@ -12,7 +12,7 @@ public void Should_BePossibleTo_Click() var welcomeForm = new WelcomeForm(); welcomeForm.Open(); welcomeForm.GetExampleLink(AvailableExample.Dropdown).MouseActions.Click(); - Assert.IsTrue(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); + Assert.That(new DropdownForm().State.WaitForDisplayed(), "Dropdown form should be displayed"); } [Test] @@ -22,7 +22,7 @@ public void Should_BePossibleTo_DoubleClick() addRemoveElementsForm.Open(); addRemoveElementsForm.AddButton.MouseActions.DoubleClick(); var addedButtonsCount = addRemoveElementsForm.ListOfDeleteButtons.Count; - Assert.AreEqual(2, addedButtonsCount, "2 elements should be added after double click"); + Assert.That(addedButtonsCount, Is.EqualTo(2), "2 elements should be added after double click"); } [Test] @@ -40,7 +40,7 @@ public void Should_BePossibleTo_MoveToElement() var menuForm = new JQueryMenuForm(); menuForm.Open(); JQueryMenuForm.EnabledButton.MouseActions.MoveToElement(); - Assert.IsTrue(JQueryMenuForm.IsEnabledButtonFocused, "Element should be focused after move mouse"); + Assert.That(JQueryMenuForm.IsEnabledButtonFocused, "Element should be focused after move mouse"); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/AlertTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/AlertTests.cs index 523370cc..35f51ca5 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/AlertTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/AlertTests.cs @@ -7,7 +7,7 @@ namespace Aquality.Selenium.Tests.Integration { internal class AlertTests : UITest { - private readonly JavaScriptAlertsForm alertsForm = new JavaScriptAlertsForm(); + private readonly JavaScriptAlertsForm alertsForm = new(); [SetUp] public void BeforeTest() @@ -20,7 +20,7 @@ public void Should_BePossibleTo_AcceptAlert() { alertsForm.JsAlertButton.Click(); AqualityServices.Browser.HandleAlert(AlertAction.Accept); - Assert.AreEqual("You successfully clicked an alert", alertsForm.ResultLabel.GetText()); + Assert.That(alertsForm.ResultLabel.GetText(), Is.EqualTo("You successfully clicked an alert")); } [Test] @@ -28,7 +28,7 @@ public void Should_BePossibleTo_AcceptConfirmationAlert() { alertsForm.JsConfirmButton.Click(); AqualityServices.Browser.HandleAlert(AlertAction.Accept); - Assert.AreEqual("You clicked: Ok", alertsForm.ResultLabel.GetText()); + Assert.That(alertsForm.ResultLabel.GetText(), Is.EqualTo("You clicked: Ok")); } [Test] @@ -50,7 +50,7 @@ public void Should_BePossibleTo_AcceptConfirmationAlert_InWaitFor() } }); - Assert.AreEqual("You clicked: Ok", alertsForm.ResultLabel.GetText()); + Assert.That(alertsForm.ResultLabel.GetText(), Is.EqualTo("You clicked: Ok")); } [Test] @@ -58,7 +58,7 @@ public void Should_BePossibleTo_DeclineConfirmationAlert() { alertsForm.JsConfirmButton.Click(); AqualityServices.Browser.HandleAlert(AlertAction.Decline); - Assert.AreEqual("You clicked: Cancel", alertsForm.ResultLabel.GetText()); + Assert.That(alertsForm.ResultLabel.GetText(), Is.EqualTo("You clicked: Cancel")); } [Test] @@ -67,7 +67,7 @@ public void Should_BePossibleTo_AcceptPromptAlertWithText() alertsForm.JsPromptButton.Click(); var text = "accept alert text"; AqualityServices.Browser.HandleAlert(AlertAction.Accept, text); - Assert.AreEqual($"You entered: {text}", alertsForm.ResultLabel.GetText()); + Assert.That(alertsForm.ResultLabel.GetText(), Is.EqualTo($"You entered: {text}")); } [Test] @@ -75,7 +75,7 @@ public void Should_BePossibleTo_DeclinePromptAlertWithText() { alertsForm.JsPromptButton.Click(); AqualityServices.Browser.HandleAlert(AlertAction.Decline, "decline alert text"); - Assert.AreEqual("You entered: null", alertsForm.ResultLabel.GetText()); + Assert.That(alertsForm.ResultLabel.GetText(), Is.EqualTo("You entered: null")); } [Test] diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs index 9f23e6c0..91dd76a4 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs @@ -8,7 +8,7 @@ namespace Aquality.Selenium.Tests.Integration { internal class BrowserTabsTests : UITest { - private readonly WelcomeForm WelcomeForm = new WelcomeForm(); + private readonly WelcomeForm WelcomeForm = new(); [SetUp] public void Before() @@ -22,8 +22,8 @@ public void Should_BePossibleTo_OpenUrlInNewTab() var url = new WelcomeForm().Url; var browser = AqualityServices.Browser; browser.Tabs().OpenInNewTab(url); - Assert.AreEqual(2, browser.Tabs().TabHandles.Count); - Assert.AreEqual(browser.Driver.Url, url); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(2)); + Assert.That(url, Is.EqualTo(browser.Driver.Url)); } [Test] @@ -32,8 +32,8 @@ public void Should_BePossibleTo_OpenUrlInNewTab_ViaJs() var url = new WelcomeForm().Url; var browser = AqualityServices.Browser; browser.Tabs().OpenInNewTabViaJs(url); - Assert.AreEqual(2, browser.Tabs().TabHandles.Count); - Assert.AreEqual(browser.Driver.Url, url); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(2)); + Assert.That(url, Is.EqualTo(browser.Driver.Url)); } [Test] @@ -42,8 +42,8 @@ public void Should_BePossibleTo_OpenUriInNewTab() var url = new Uri(new WelcomeForm().Url); var browser = AqualityServices.Browser; browser.Tabs().OpenInNewTab(url); - Assert.AreEqual(2, browser.Tabs().TabHandles.Count); - Assert.AreEqual(new Uri(browser.Driver.Url), url); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(2)); + Assert.That(url, Is.EqualTo(new Uri(browser.Driver.Url))); } [Test] @@ -51,7 +51,7 @@ public void Should_BePossibleTo_HandleTab() { var browser = AqualityServices.Browser; var tabHandle = browser.Tabs().CurrentTabHandle; - Assert.IsNotEmpty(tabHandle, "Tab name should not be empty"); + Assert.That(tabHandle, Is.Not.Empty, "Tab name should not be empty"); } [Test] @@ -59,8 +59,8 @@ public void Should_BePossibleTo_GetTabHandles() { var browser = AqualityServices.Browser; var tabHandles = browser.Tabs().TabHandles; - Assert.AreEqual(1, tabHandles.Count, "Tab number should be correct"); - Assert.IsNotEmpty(tabHandles.First(), "Tab handle should not be empty"); + Assert.That(tabHandles.Count, Is.EqualTo(1), "Tab number should be correct"); + Assert.That(tabHandles.First(), Is.Not.Empty, "Tab handle should not be empty"); } [Test] @@ -71,12 +71,12 @@ public void Should_BePossibleTo_OpenNewTab() browser.Tabs().OpenNewTab(); var newTabHandle = browser.Tabs().CurrentTabHandle; - Assert.AreEqual(2, browser.Tabs().TabHandles.Count, "New tab should be opened"); - Assert.AreNotEqual(tabHandle, newTabHandle, "Browser should be switched to new tab"); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(2), "New tab should be opened"); + Assert.That(newTabHandle, Is.Not.EqualTo(tabHandle), "Browser should be switched to new tab"); browser.Tabs().OpenNewTab(false); - Assert.AreEqual(3, browser.Tabs().TabHandles.Count, "New tab should be opened"); - Assert.AreEqual(newTabHandle, browser.Tabs().CurrentTabHandle, "Browser should not be switched to new tab"); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(3), "New tab should be opened"); + Assert.That(browser.Tabs().CurrentTabHandle, Is.EqualTo(newTabHandle), "Browser should not be switched to new tab"); } [Test] @@ -87,12 +87,12 @@ public void Should_BePossibleTo_OpenNewTab_ViaJs() browser.Tabs().OpenNewTabViaJs(); var newTabHandle = browser.Tabs().CurrentTabHandle; - Assert.AreEqual(2, browser.Tabs().TabHandles.Count, "New tab should be opened"); - Assert.AreNotEqual(tabHandle, newTabHandle, "Browser should be switched to new tab"); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(2), "New tab should be opened"); + Assert.That(newTabHandle, Is.Not.EqualTo(tabHandle), "Browser should be switched to new tab"); browser.Tabs().OpenNewTabViaJs(false); - Assert.AreEqual(3, browser.Tabs().TabHandles.Count, "New tab should be opened"); - Assert.AreEqual(newTabHandle, browser.Tabs().CurrentTabHandle, "Browser should not be switched to new tab"); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(3), "New tab should be opened"); + Assert.That(browser.Tabs().CurrentTabHandle, Is.EqualTo(newTabHandle), "Browser should not be switched to new tab"); } [Test] @@ -100,9 +100,9 @@ public void Should_BePossibleTo_CloseTab() { var browser = AqualityServices.Browser; WelcomeForm.ClickElementalSelenium(); - Assert.AreEqual(2, browser.Tabs().TabHandles.Count, "New tab should be opened"); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(2), "New tab should be opened"); browser.Tabs().CloseTab(); - Assert.AreEqual(1, browser.Tabs().TabHandles.Count, "New tab should be closed"); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(1), "New tab should be closed"); } [Test] @@ -177,11 +177,12 @@ private void CheckSwitchingBy(int expectedTabCount, Action switchMethod) { var browser = AqualityServices.Browser; var tabHandle = browser.Tabs().CurrentTabHandle; + Assert.That(tabHandle, Is.Not.Empty); WelcomeForm.ClickElementalSelenium(); var newTabHandle = browser.Tabs().TabHandles.Last(); switchMethod.Invoke(); - Assert.AreEqual(newTabHandle, browser.Tabs().CurrentTabHandle, "Browser should be switched to correct tab"); - Assert.AreEqual(expectedTabCount, browser.Tabs().TabHandles.Count, "Number of tabs should be correct"); + Assert.That(browser.Tabs().CurrentTabHandle, Is.EqualTo(newTabHandle), "Browser should be switched to correct tab"); + Assert.That(browser.Tabs().TabHandles.Count, Is.EqualTo(expectedTabCount), "Number of tabs should be correct"); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs index d48b4d60..5b9bc6f8 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs @@ -19,7 +19,7 @@ public void Should_BePossibleTo_StartBrowserAndNavigate() var url = new WelcomeForm().Url; var browser = AqualityServices.Browser; browser.GoTo(url); - Assert.AreEqual(browser.CurrentUrl, url); + Assert.That(browser.CurrentUrl, Is.EqualTo(url)); } [Test] @@ -28,7 +28,7 @@ public void Should_BePossibleTo_GetWebDriverInstance() var url = new WelcomeForm().Url; var browser = AqualityServices.Browser; browser.Driver.Navigate().GoToUrl(url); - Assert.AreEqual(browser.Driver.Url, url); + Assert.That(browser.Driver.Url, Is.EqualTo(url)); } [Test] @@ -39,16 +39,16 @@ public void Should_BePossibleTo_NavigateBackAndForward() var browser = AqualityServices.Browser; browser.GoTo(firstNavigationUrl); - Assert.AreEqual(browser.CurrentUrl, firstNavigationUrl); + Assert.That(browser.CurrentUrl, Is.EqualTo(firstNavigationUrl)); browser.GoTo(secondNavigationUrl); - Assert.AreEqual(browser.CurrentUrl, secondNavigationUrl); + Assert.That(browser.CurrentUrl, Is.EqualTo(secondNavigationUrl)); browser.GoBack(); - Assert.AreEqual(browser.CurrentUrl, firstNavigationUrl); + Assert.That(browser.CurrentUrl, Is.EqualTo(firstNavigationUrl)); browser.GoForward(); - Assert.AreEqual(browser.CurrentUrl, secondNavigationUrl); + Assert.That(browser.CurrentUrl, Is.EqualTo(secondNavigationUrl)); } [Test] @@ -58,7 +58,7 @@ public void Should_BePossibleTo_OpenNewBrowserAfterQuit() welcomeForm.Open(); AqualityServices.Browser.Quit(); - Assert.AreNotEqual(welcomeForm.Url, AqualityServices.Browser.CurrentUrl); + Assert.That(AqualityServices.Browser.CurrentUrl, Is.Not.EqualTo(welcomeForm.Url)); } [Test] @@ -73,7 +73,7 @@ public void Should_BePossibleTo_RefreshPage() browser.WaitForPageToLoad(); var firstItemAfterRefresh = dynamicContentForm.GetContentItem(1).GetText(); - Assert.AreNotEqual(firstItem, firstItemAfterRefresh); + Assert.That(firstItemAfterRefresh, Is.Not.EqualTo(firstItem)); } [Test] @@ -88,7 +88,7 @@ public void Should_BePossibleTo_SetPageLoadTimeout() public void Should_BePossibleTo_TakeScreenshot() { new DynamicContentForm().Open(); - Assert.IsTrue(AqualityServices.Browser.GetScreenshot().Length > 0); + Assert.That(AqualityServices.Browser.GetScreenshot().Length > 0); } [Test] @@ -97,7 +97,7 @@ public void Should_BePossibleTo_ExecuteJavaScript() var dynamicContentForm = new DynamicContentForm(); dynamicContentForm.Open(); var currentUrl = AqualityServices.Browser.ExecuteScript("return window.location.href"); - Assert.AreEqual(dynamicContentForm.Url, currentUrl); + Assert.That(currentUrl, Is.EqualTo(dynamicContentForm.Url)); } [Test] @@ -116,8 +116,8 @@ public void Should_BePossibleTo_ExecuteAsyncJavaScript() Assert.Multiple(() => { - Assert.Less(durationSeconds, (expectedDurationInSeconds + operationDurationInSeconds), "Elapsed time should be less than (js + operation) duration"); - Assert.GreaterOrEqual(durationSeconds, expectedDurationInSeconds, "Elapsed time should be greater or equal than js duration"); + Assert.That(durationSeconds, Is.LessThan(expectedDurationInSeconds + operationDurationInSeconds), "Elapsed time should be less than (js + operation) duration"); + Assert.That(durationSeconds, Is.GreaterThanOrEqualTo(expectedDurationInSeconds), "Elapsed time should be greater or equal than js duration"); }); } @@ -129,7 +129,7 @@ public void Should_BePossibleTo_ExecuteAsyncJavaScript_WithScriptTimeoutExceptio Assert.Throws(() => AqualityServices.Browser.ExecuteAsyncScript(GetAsyncTimeoutJavaScript(expectedDurationInSeconds))); } - private string GetAsyncTimeoutJavaScript(double expectedDurationInSeconds) + private static string GetAsyncTimeoutJavaScript(double expectedDurationInSeconds) { return $"window.setTimeout(arguments[arguments.length - 1], {expectedDurationInSeconds * 1000});"; } @@ -140,7 +140,7 @@ public void Should_BePossibleTo_ExecuteJavaScriptFromFile() var dynamicContentForm = new DynamicContentForm(); dynamicContentForm.Open(); var currentUrl = AqualityServices.Browser.ExecuteScriptFromFile("Resources.GetCurrentUrl.js"); - Assert.AreEqual(dynamicContentForm.Url, currentUrl); + Assert.That(currentUrl, Is.EqualTo(dynamicContentForm.Url)); } [Test] @@ -150,7 +150,7 @@ public void Should_BePossibleTo_ExecuteJavaScriptFromPredefinedFile() var authForm = new TheInternetAuthenticationForm(); authForm.Open(); AqualityServices.Browser.ExecuteScript(JavaScript.SetValue, authForm.UserNameTextBox.GetElement(), valueToSet); - Assert.AreEqual(valueToSet, authForm.UserNameTextBox.Value); + Assert.That(authForm.UserNameTextBox.Value, Is.EqualTo(valueToSet)); } [Test] @@ -166,22 +166,22 @@ public void Should_BePossibleTo_SetWindowSize() var currentSize = browser.Driver.Manage().Window.Size; Assert.Multiple(() => { - Assert.IsTrue(currentSize.Height < initialSize.Height); - Assert.IsTrue(currentSize.Width < initialSize.Width); - Assert.IsTrue(currentSize.Width >= testSize.Width); + Assert.That(currentSize.Height < initialSize.Height); + Assert.That(currentSize.Width < initialSize.Width); + Assert.That(currentSize.Width >= testSize.Width); }); browser.Maximize(); currentSize = browser.Driver.Manage().Window.Size; Assert.Multiple(() => { - Assert.AreNotEqual(currentSize, testSize); - Assert.IsTrue(currentSize.Height > testSize.Height); - Assert.IsTrue(currentSize.Width > testSize.Width); + Assert.That(currentSize, Is.Not.EqualTo(testSize)); + Assert.That(currentSize.Height > testSize.Height); + Assert.That(currentSize.Width > testSize.Width); }); browser.SetWindowSize(defaultSize.Width, defaultSize.Height); - Assert.AreEqual(browser.Driver.Manage().Window.Size, defaultSize); + Assert.That(defaultSize, Is.EqualTo(browser.Driver.Manage().Window.Size)); } [Test] @@ -207,7 +207,7 @@ public void Should_BePossibleTo_GetBrowserName() var settingsProfile = profileNameFromEnvironment == null ? "settings.json" : $"settings.{profileNameFromEnvironment}.json"; var settingsFile = new JsonSettingsFile(settingsProfile); var browserName = (BrowserName)Enum.Parse(typeof(BrowserName), settingsFile.GetValue(".browserName"), ignoreCase: true); - Assert.AreEqual(browserName, AqualityServices.Browser.BrowserName); + Assert.That(AqualityServices.Browser.BrowserName, Is.EqualTo(browserName)); } [Test] @@ -230,9 +230,9 @@ public void Should_BePossibleTo_SetImplicitWait() } Assert.Multiple(() => { - Assert.Less(elapsedTime, waitTime.Add(TimeSpan.FromSeconds(2)), + Assert.That(elapsedTime, Is.LessThan(waitTime.Add(TimeSpan.FromSeconds(2))), $"Elapsed time should be less than implicit timeout + 2 sec(accuracy). Elapsed time: {elapsedTime.Seconds}"); - Assert.GreaterOrEqual(elapsedTime, waitTime, "Elapsed time should be greater or equal than implicit timeout"); + Assert.That(elapsedTime, Is.GreaterThanOrEqualTo(waitTime), "Elapsed time should be greater or equal than implicit timeout"); }); } @@ -240,7 +240,7 @@ public void Should_BePossibleTo_SetImplicitWait() public void Should_BePossibleTo_GetDownloadDir() { var downloadDir = AqualityServices.Browser.DownloadDirectory; - Assert.IsTrue(downloadDir.ToLower().Contains("downloads", StringComparison.InvariantCultureIgnoreCase)); + Assert.That(downloadDir.ToLower().Contains("downloads", StringComparison.InvariantCultureIgnoreCase)); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs index dfac4bac..baac0afe 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs @@ -30,13 +30,13 @@ internal class DevToolsEmulationTests : UITest [Test] public void Should_BePossibleTo_GetAndCloseDevToolsSession() { - Assert.IsFalse(DevTools.HasActiveDevToolsSession, "No DevTools session should be running initially"); - Assert.IsNotNull(DevTools.GetDevToolsSession(), "Should be possible to get DevTools session"); - Assert.IsTrue(DevTools.HasActiveDevToolsSession, "DevTools session should be indicated as active after getting"); + Assert.That(DevTools.HasActiveDevToolsSession, Is.False, "No DevTools session should be running initially"); + Assert.That(DevTools.GetDevToolsSession(), Is.Not.Null, "Should be possible to get DevTools session"); + Assert.That(DevTools.HasActiveDevToolsSession, "DevTools session should be indicated as active after getting"); Assert.DoesNotThrow(() => DevTools.CloseDevToolsSession(), "Should be possible to close DevTools session"); - Assert.IsFalse(DevTools.HasActiveDevToolsSession, "DevTools session should be indicated as not active after close"); - Assert.IsNotNull(DevTools.GetDevToolsSession(), "Should be possible to get a new DevTools session after close"); - Assert.IsTrue(DevTools.HasActiveDevToolsSession, "DevTools session should be indicated as active after getting for a second time"); + Assert.That(DevTools.HasActiveDevToolsSession, Is.False, "DevTools session should be indicated as not active after close"); + Assert.That(DevTools.GetDevToolsSession(), Is.Not.Null, "Should be possible to get a new DevTools session after close"); + Assert.That(DevTools.HasActiveDevToolsSession, "DevTools session should be indicated as active after getting for a second time"); } [Test] @@ -44,7 +44,7 @@ public void Should_BePossibleTo_CheckThatBrowserCanEmulate() { var canEmulate = false; Assert.DoesNotThrowAsync(async () => canEmulate = await DevTools.CanEmulate(), "Should be possible to check that browser can emulate"); - Assert.IsTrue(canEmulate, "Emulation should be supported in browser"); + Assert.That(canEmulate, "Emulation should be supported in browser"); } [Test] @@ -59,11 +59,11 @@ public void Should_BePossibleTo_SetAndClearDeviceMetricsOverride_WithVersionSpec { void setAction(long width, long height, bool isMobile, double scaleFactor) { - var parameters = new OpenQA.Selenium.DevTools.V120.Emulation.SetDeviceMetricsOverrideCommandSettings + var parameters = new OpenQA.Selenium.DevTools.V123.Emulation.SetDeviceMetricsOverrideCommandSettings { - DisplayFeature = new OpenQA.Selenium.DevTools.V120.Emulation.DisplayFeature + DisplayFeature = new OpenQA.Selenium.DevTools.V123.Emulation.DisplayFeature { - Orientation = OpenQA.Selenium.DevTools.V120.Emulation.DisplayFeatureOrientationValues.Horizontal + Orientation = OpenQA.Selenium.DevTools.V123.Emulation.DisplayFeatureOrientationValues.Horizontal }, Width = width, Height = height, @@ -85,12 +85,12 @@ private static void CheckDeviceMetricsOverride(Action var initialValue = getWindowHeight(); Assume.That(initialValue, Is.Not.EqualTo(DeviceModeSettingHeight), "To check that override works, initial value should differ from the new one"); setAction(DeviceModeSettingWidth, DeviceModeSettingHeight, DeviceModeSettingMobile, DeviceModeSettingDeviceScaleFactor); - Assert.AreEqual(DeviceModeSettingHeight, getWindowHeight(), "Browser height should match to override value"); + Assert.That(getWindowHeight(), Is.EqualTo(DeviceModeSettingHeight), "Browser height should match to override value"); Assert.DoesNotThrowAsync(async () => await DevTools.ClearDeviceMetricsOverride(), "Should be possible to clear device metrics override"); AqualityServices.Browser.Refresh(); AqualityServices.Browser.WaitForPageToLoad(); - Assert.AreEqual(initialValue, getWindowHeight(), "Browser height should match to initial value after clear"); + Assert.That(getWindowHeight(), Is.EqualTo(initialValue), "Browser height should match to initial value after clear"); } [Test] @@ -133,15 +133,15 @@ private static void CheckGeolocationOverride(Action s setAction(LatitudeForOverride, LongitudeForOverride, Accuracy); AqualityServices.Browser.Refresh(); locationForm.DetectBrowserGeolocation(); - Assert.AreEqual(LatitudeForOverride, locationForm.Latitude, "Latitude should match to override value"); - Assert.AreEqual(LongitudeForOverride, locationForm.Longitude, "Longitude should match to override value"); + Assert.That(locationForm.Latitude, Is.EqualTo(LatitudeForOverride), "Latitude should match to override value"); + Assert.That(locationForm.Longitude, Is.EqualTo(LongitudeForOverride), "Longitude should match to override value"); clearAction(); AqualityServices.Browser.WaitForPageToLoad(); AqualityServices.Browser.Refresh(); locationForm.DetectBrowserGeolocation(); - Assert.AreEqual(defaultLatitude, locationForm.Latitude, "Latitude should match to default"); - Assert.AreEqual(defaultLongitude, locationForm.Longitude, "Longitude should match to default"); + Assert.That(locationForm.Latitude, Is.EqualTo(defaultLatitude), "Latitude should match to default"); + Assert.That(locationForm.Longitude, Is.EqualTo(defaultLongitude), "Longitude should match to default"); } [Test] @@ -154,8 +154,8 @@ public void Should_BePossibleTo_SetUserAgentAndLanguageOverride() Assume.That(defaultUserAgent, Is.Not.EqualTo(CustomUserAgent), "Default user agent header should be different from the custom one to check override"); Assert.DoesNotThrowAsync(async () => await DevTools.SetUserAgentOverride(CustomUserAgent, CustomAcceptLanguage), "Should be possible to set user agent override"); - StringAssert.Contains(CustomAcceptLanguage, new BrowserLanguageForm().Open().Value, "Accept-language header should match to value set"); - Assert.AreEqual(CustomUserAgent, new UserAgentForm().Open().Value, "User agent should match to value set"); + Assert.That(new BrowserLanguageForm().Open().Value, Does.Contain(CustomAcceptLanguage), "Accept-language header should match to value set"); + Assert.That(new UserAgentForm().Open().Value, Is.EqualTo(CustomUserAgent), "User agent should match to value set"); } [Test] @@ -182,10 +182,10 @@ public void Should_BePossibleTo_SetTouchEmulationEnabled_AndDisabled() Assume.That(isTouchEnabled, Is.False, "Touch should be initially disabled"); Assert.DoesNotThrowAsync(async () => await DevTools.SetTouchEmulationEnabled(true), "Should be possible to enable touch emulation"); - Assert.IsTrue(isTouchEnabled(), "Touch should be enabled"); + Assert.That(isTouchEnabled(), "Touch should be enabled"); Assert.DoesNotThrowAsync(async () => await DevTools.SetTouchEmulationEnabled(new SetTouchEmulationEnabledCommandSettings { Enabled = false }), "Should be possible to disable touch emulation"); - Assert.IsFalse(isTouchEnabled(), "Touch should be disabled"); + Assert.That(isTouchEnabled(), Is.False, "Touch should be disabled"); } [Test] @@ -199,9 +199,9 @@ public void Should_BePossibleTo_SetEmulatedMedia() Assert.DoesNotThrowAsync(async () => await DevTools.SetEmulatedMedia(emulatedMedia, new Dictionary { { "width", DeviceModeSettingWidth.ToString() } }), "Should be possible to set emulated media"); - Assert.AreEqual(emulatedMedia, getMediaType(), "Media type should equal to emulated"); + Assert.That(getMediaType(), Is.EqualTo(emulatedMedia), "Media type should equal to emulated"); Assert.DoesNotThrowAsync(async () => await DevTools.DisableEmulatedMediaOverride(), "Should be possible to disable emulated media override"); - Assert.AreEqual(initialValue, getMediaType(), "Media type should equal to initial after disabling the override"); + Assert.That(getMediaType(), Is.EqualTo(initialValue), "Media type should equal to initial after disabling the override"); } [Test] diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs index 4db4b426..21375426 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsPerformanceTests.cs @@ -16,16 +16,16 @@ public void Should_BePossibleTo_CollectPerformanceMetrics() AqualityServices.Browser.GoTo("http://www.google.com"); IDictionary metrics = null; Assert.DoesNotThrowAsync(async () => metrics = await DevTools.GetPerformanceMetrics(), "Should be possible to get performance metrics"); - CollectionAssert.IsNotEmpty(metrics, "Some metrics should be returned"); + Assert.That(metrics, Is.Not.Empty, "Some metrics should be returned"); AqualityServices.Browser.Refresh(); IDictionary otherMetrics = DevTools.GetPerformanceMetrics().GetAwaiter().GetResult(); - CollectionAssert.AreNotEqual(otherMetrics, metrics, "Some additional metrics should have been collected"); + Assert.That(otherMetrics, Is.Not.EqualTo(metrics), "Some additional metrics should have been collected"); Assert.DoesNotThrowAsync(async () => await DevTools.DisablePerfomanceMonitoring(), "Should be possible to disable performance monitoring"); AqualityServices.Browser.Refresh(); metrics = DevTools.GetPerformanceMetrics().GetAwaiter().GetResult(); - CollectionAssert.IsEmpty(metrics, "Metrics should have not been collected after performance monitoring have been disabled"); + Assert.That(metrics, Is.Empty, "Metrics should have not been collected after performance monitoring have been disabled"); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs index 12902939..d8b7fbff 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ElementStateTests.cs @@ -6,7 +6,7 @@ namespace Aquality.Selenium.Tests.Integration { internal class ElementStateTests : UITest { - private readonly DynamicControlsForm dynamicControlsForm = new DynamicControlsForm(); + private readonly DynamicControlsForm dynamicControlsForm = new(); [SetUp] public void BeforeTest() @@ -19,8 +19,8 @@ public void Should_BePossibleTo_CheckEnabledElementState() { Assert.Multiple(() => { - Assert.IsTrue(dynamicControlsForm.ChangeInputStateButton.State.IsEnabled, "Change state button should be enabled"); - Assert.IsFalse(dynamicControlsForm.TextInputTextBox.State.IsEnabled, "Text input should be disabled"); + Assert.That(dynamicControlsForm.ChangeInputStateButton.State.IsEnabled, "Change state button should be enabled"); + Assert.That(dynamicControlsForm.TextInputTextBox.State.IsEnabled, Is.False, "Text input should be disabled"); }); } @@ -29,17 +29,17 @@ public void Should_BePossibleTo_CheckDisplayedElementState() { Assert.Multiple(() => { - Assert.IsTrue(dynamicControlsForm.TextInputTextBox.State.IsDisplayed, "Text input should be displayed"); - Assert.IsFalse(dynamicControlsForm.LoadingLabel.State.IsDisplayed, "Loading should not be displayed"); + Assert.That(dynamicControlsForm.TextInputTextBox.State.IsDisplayed, "Text input should be displayed"); + Assert.That(dynamicControlsForm.LoadingLabel.State.IsDisplayed, Is.False, "Loading should not be displayed"); }); } [Test] public void Should_BePossibleTo_CheckExistElementState() { - Assert.IsFalse(dynamicControlsForm.LoadingLabel.State.IsExist, "Loading element should not be exist by default"); + Assert.That(dynamicControlsForm.LoadingLabel.State.IsExist, Is.False, "Loading element should not be exist by default"); dynamicControlsForm.ChangeInputStateButton.Click(); - Assert.IsTrue(dynamicControlsForm.LoadingLabel.State.IsExist, "Loading element should not exist after changing state"); + Assert.That(dynamicControlsForm.LoadingLabel.State.IsExist, "Loading element should not exist after changing state"); } [Test] @@ -47,37 +47,37 @@ public void Should_BePossibleTo_CheckElementIsClickableState() { Assert.Multiple(() => { - Assert.IsTrue(dynamicControlsForm.ChangeInputStateButton.State.IsClickable, "Change state button should be clickable"); - Assert.IsFalse(dynamicControlsForm.TextInputTextBox.State.IsClickable, "Text input should not be clickable"); + Assert.That(dynamicControlsForm.ChangeInputStateButton.State.IsClickable, "Change state button should be clickable"); + Assert.That(dynamicControlsForm.TextInputTextBox.State.IsClickable, Is.False, "Text input should not be clickable"); }); } [Test] public void Should_BePossibleTo_WaitForElementEnabledState() { - Assert.IsTrue(dynamicControlsForm.State.WaitForDisplayed(), "Form 'Dynamic Controls' should be displayed"); + Assert.That(dynamicControlsForm.State.WaitForDisplayed(), "Form 'Dynamic Controls' should be displayed"); dynamicControlsForm.ChangeInputStateButton.Click(); - Assert.IsTrue(dynamicControlsForm.TextInputTextBox.State.WaitForEnabled(), "Text input should be enable after changing state"); + Assert.That(dynamicControlsForm.TextInputTextBox.State.WaitForEnabled(), "Text input should be enable after changing state"); dynamicControlsForm.ChangeInputStateButton.Click(); - Assert.IsTrue(dynamicControlsForm.TextInputTextBox.State.WaitForNotEnabled(), "Text input should be disabled after changing state"); + Assert.That(dynamicControlsForm.TextInputTextBox.State.WaitForNotEnabled(), "Text input should be disabled after changing state"); } [Test] public void Should_BePossibleTo_WaitForElementDisplayedState() { dynamicControlsForm.RemoveAddExampleButton.Click(); - Assert.IsTrue(dynamicControlsForm.ExampleCheckbox.State.WaitForNotDisplayed(), "Checkbox example should not be displayed after removing"); + Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForNotDisplayed(), "Checkbox example should not be displayed after removing"); dynamicControlsForm.RemoveAddExampleButton.Click(); - Assert.IsTrue(dynamicControlsForm.ExampleCheckbox.State.WaitForDisplayed(), "Checkbox example should be displayed after adding"); + Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForDisplayed(), "Checkbox example should be displayed after adding"); } [Test] public void Should_BePossibleTo_WaitForElementExistState() { dynamicControlsForm.RemoveAddExampleButton.Click(); - Assert.IsTrue(dynamicControlsForm.ExampleCheckbox.State.WaitForNotExist(), "Checkbox example should not be exist after removing"); + Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForNotExist(), "Checkbox example should not be exist after removing"); dynamicControlsForm.RemoveAddExampleButton.Click(); - Assert.IsTrue(dynamicControlsForm.ExampleCheckbox.State.WaitForExist(), "Checkbox example should be exist after adding"); + Assert.That(dynamicControlsForm.ExampleCheckbox.State.WaitForExist(), "Checkbox example should be exist after adding"); } [Test] @@ -86,7 +86,7 @@ public void Should_BePossibleTo_WaitForElementIsClickable() Assert.Throws(() => dynamicControlsForm.TextInputTextBox.State.WaitForClickable(), "Textbox should not be clickable"); dynamicControlsForm.ChangeInputStateButton.Click(); dynamicControlsForm.TextInputTextBox.State.WaitForClickable(); - Assert.IsTrue(dynamicControlsForm.TextInputTextBox.State.IsClickable, "Textbox should not be clickable after changing state"); + Assert.That(dynamicControlsForm.TextInputTextBox.State.IsClickable, "Textbox should not be clickable after changing state"); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/CheckBoxTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/CheckBoxTests.cs index 78d5bf5c..188637bc 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/CheckBoxTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/CheckBoxTests.cs @@ -5,7 +5,7 @@ namespace Aquality.Selenium.Tests.Integration.Elements { internal class CheckBoxTests : UITest { - private readonly CheckBoxesForm checkBoxesForm = new CheckBoxesForm(); + private readonly CheckBoxesForm checkBoxesForm = new(); [SetUp] public void BeforeTest() @@ -19,7 +19,7 @@ public void Should_BePossibleTo_Toggle() var checkBox1 = checkBoxesForm.FirstCheckBox; var checkBox1State = checkBox1.IsChecked; checkBox1.Toggle(); - Assert.AreEqual(!checkBox1State, checkBox1.IsChecked); + Assert.That(checkBox1.IsChecked, Is.EqualTo(!checkBox1State)); } [Test] @@ -27,7 +27,7 @@ public void Should_BePossibleTo_Uncheck() { var checkBox = checkBoxesForm.SecondCheckBox; checkBox.Uncheck(); - Assert.IsFalse(checkBox.IsChecked); + Assert.That(checkBox.IsChecked, Is.False); } [Test] @@ -35,7 +35,7 @@ public void Should_BePossibleTo_Check() { var checkBox = checkBoxesForm.FirstCheckBox; checkBox.Check(); - Assert.IsTrue(checkBox.IsChecked); + Assert.That(checkBox.IsChecked, Is.True); } [Test] @@ -49,8 +49,8 @@ public void Should_BePossibleTo_GetStateViaJsActions() Assert.Multiple(() => { - Assert.IsTrue(checkBox1.JsActions.IsChecked()); - Assert.IsFalse(checkBox2.JsActions.IsChecked()); + Assert.That(checkBox1.JsActions.IsChecked()); + Assert.That(checkBox2.JsActions.IsChecked(), Is.False); }); } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/ComboBoxTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/ComboBoxTests.cs index 6d0bfc2a..6ffffcd9 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/ComboBoxTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/ComboBoxTests.cs @@ -8,7 +8,7 @@ internal class ComboBoxTests : UITest { private static readonly string Option2 = "Option 2"; - private readonly DropdownForm dropdownForm = new DropdownForm(); + private readonly DropdownForm dropdownForm = new(); [SetUp] public void BeforeTest() @@ -23,7 +23,7 @@ public void Should_BePossibleTo_SelectValueByIndex() var values = comboBox.Values; var itemIndex = values.Count - 1; comboBox.SelectByIndex(itemIndex); - Assert.AreEqual(values[itemIndex], comboBox.SelectedValue); + Assert.That(comboBox.SelectedValue, Is.EqualTo(values[itemIndex])); } [Test] @@ -33,7 +33,7 @@ public void Should_BePossibleTo_SelectByText() var selectedText = comboBox.SelectedText; comboBox.SelectByText(Option2); AqualityServices.ConditionalWait.WaitFor(() => !selectedText.Equals(comboBox.SelectedText)); - Assert.AreEqual(comboBox.Texts[2], comboBox.JsActions.GetSelectedText()); + Assert.That(comboBox.JsActions.GetSelectedText(), Is.EqualTo(comboBox.Texts[2])); } [Test] @@ -43,7 +43,7 @@ public void Should_BePossibleTo_SelectByValue() var selectedText = comboBox.SelectedText; comboBox.SelectByValue("2"); AqualityServices.ConditionalWait.WaitFor(() => !selectedText.Equals(comboBox.SelectedText)); - Assert.AreEqual(comboBox.Texts[2], comboBox.JsActions.GetSelectedText()); + Assert.That(comboBox.JsActions.GetSelectedText(), Is.EqualTo(comboBox.Texts[2])); } [Test] @@ -51,7 +51,7 @@ public void Should_BePossibleTo_SelectByContainingText() { var comboBox = dropdownForm.ComboBox; comboBox.SelectByContainingText("1"); - Assert.AreEqual(comboBox.Texts[1], comboBox.SelectedText); + Assert.That(comboBox.SelectedText, Is.EqualTo(comboBox.Texts[1])); } [Test] @@ -59,21 +59,21 @@ public void Should_BePossibleTo_SelectByContainingValue() { var comboBox = dropdownForm.ComboBox; comboBox.SelectByContainingValue("2"); - Assert.AreEqual(comboBox.Values[2], comboBox.SelectedValue); + Assert.That(comboBox.SelectedValue, Is.EqualTo(comboBox.Values[2])); } [Test] public void Should_BePossibleTo_GetTextsViaJsActions() { var comboBox = dropdownForm.ComboBox; - CollectionAssert.AreEqual(comboBox.Texts, comboBox.JsActions.GetTexts()); + Assert.That(comboBox.JsActions.GetTexts(), Is.EquivalentTo(comboBox.Texts)); } [Test] public void Should_BePossibleTo_GetSelectedTextViaJsActions() { var comboBox = dropdownForm.ComboBox; - Assert.AreEqual(comboBox.SelectedText, comboBox.JsActions.GetSelectedText()); + Assert.That(comboBox.JsActions.GetSelectedText(), Is.EqualTo(comboBox.SelectedText)); } [Test] @@ -81,7 +81,7 @@ public void Should_BePossibleTo_SelectValueViaJsActions() { var comboBox = dropdownForm.ComboBox; comboBox.JsActions.SelectValueByText(Option2); - Assert.AreEqual(comboBox.SelectedText, Option2); + Assert.That(Option2, Is.EqualTo(comboBox.SelectedText)); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/LinkTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/LinkTests.cs index 93e92f10..403aaa88 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/LinkTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/LinkTests.cs @@ -7,7 +7,7 @@ namespace Aquality.Selenium.Tests.Integration.Elements { internal class LinkTests : UITest { - private readonly RedirectorForm redirectorForm = new RedirectorForm(); + private readonly RedirectorForm redirectorForm = new(); [SetUp] public void BeforeTest() @@ -21,7 +21,7 @@ public void Should_BePossibleTo_Click() var link = redirectorForm.RedirectLink; link.Click(); WaitForRedirect(); - Assert.AreEqual(new StatusCodesForm().Url.ToLower(), AqualityServices.Browser.CurrentUrl.ToLower()); + Assert.That(AqualityServices.Browser.CurrentUrl.ToLower(), Is.EqualTo(new StatusCodesForm().Url.ToLower())); } [Test] @@ -30,10 +30,10 @@ public void Should_BePossibleTo_GetHref() var link = redirectorForm.RedirectLink; AqualityServices.Browser.GoTo(link.Href); WaitForRedirect(); - Assert.AreEqual(new StatusCodesForm().Url.ToLower(), AqualityServices.Browser.CurrentUrl.ToLower()); + Assert.That(AqualityServices.Browser.CurrentUrl.ToLower(), Is.EqualTo(new StatusCodesForm().Url.ToLower())); } - private void WaitForRedirect() + private static void WaitForRedirect() { AqualityServices.ConditionalWait.WaitFor(() => AqualityServices.Browser.CurrentUrl.Equals(new StatusCodesForm().Url, StringComparison.OrdinalIgnoreCase)); } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/MultiChoiceBoxTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/MultiChoiceBoxTests.cs index 4c704c2d..d7f0c99f 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/MultiChoiceBoxTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/MultiChoiceBoxTests.cs @@ -9,7 +9,7 @@ namespace Aquality.Selenium.Tests.Integration.Elements [Parallelizable(ParallelScope.None)] internal class MultiChoiceBoxTests : UITest { - private readonly SelectMultipleForm selectMultipleForm = new SelectMultipleForm(); + private readonly SelectMultipleForm selectMultipleForm = new(); [SetUp] public void BeforeTest() @@ -26,12 +26,12 @@ public void Should_BePossibleTo_SelectAll() selectMultipleForm.SelectAll(); var selected = selectMultipleForm.SelectedTexts; - Assert.AreEqual(selected, allTexts, "Not all texts were selected"); + Assert.That(allTexts, Is.EqualTo(selected), "Not all texts were selected"); selected = selectMultipleForm.SelectedValues; selectMultipleForm.Submit(); - Assert.AreEqual(selected, selectMultipleForm.ValuesFromResult); + Assert.That(selectMultipleForm.ValuesFromResult, Is.EqualTo(selected)); } [Test] @@ -43,7 +43,7 @@ public void Should_BePossibleTo_DeselectByValue() var remaining = selectMultipleForm.DeselectByValue(valuesToRemove); selectMultipleForm.Submit(); - Assert.AreEqual(remaining, selectMultipleForm.ValuesFromResult); + Assert.That(selectMultipleForm.ValuesFromResult, Is.EqualTo(remaining)); } [Test] @@ -55,7 +55,7 @@ public void Should_BePossibleTo_DeselectByContainingValue() var remaining = selectMultipleForm.DeselectByContainingValue(valuesToRemove); selectMultipleForm.Submit(); - Assert.AreEqual(remaining, selectMultipleForm.ValuesFromResult); + Assert.That(selectMultipleForm.ValuesFromResult, Is.EqualTo(remaining)); } [Test] @@ -67,7 +67,7 @@ public void Should_BePossibleTo_DeselectByText() var remaining = selectMultipleForm.DeselectByText(valuesToRemove); selectMultipleForm.Submit(); - Assert.AreEqual(remaining, selectMultipleForm.ValuesFromResult); + Assert.That(selectMultipleForm.ValuesFromResult, Is.EqualTo(remaining)); } [Test] @@ -79,7 +79,7 @@ public void Should_BePossibleTo_DeselectByContainingText() var remaining = selectMultipleForm.DeselectByContainingText(valuesToRemove); selectMultipleForm.Submit(); - Assert.AreEqual(remaining, selectMultipleForm.ValuesFromResult); + Assert.That(selectMultipleForm.ValuesFromResult, Is.EqualTo(remaining)); } [Test] @@ -91,7 +91,7 @@ public void Should_BePossibleTo_DeselectByIndex() var remaining = selectMultipleForm.DeselectByIndex(valuesToRemove); selectMultipleForm.Submit(); - Assert.AreEqual(remaining, selectMultipleForm.ValuesFromResult); + Assert.That(selectMultipleForm.ValuesFromResult, Is.EqualTo(remaining)); } [Test] @@ -101,7 +101,7 @@ public void Should_BePossibleTo_DeselectAll() selectMultipleForm.DeselectAll(); selectMultipleForm.Submit(); - Assert.False(selectMultipleForm.ValuesFromResult.Any()); + Assert.That(selectMultipleForm.ValuesFromResult.Any(), Is.False); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs index 5016f9e3..8f1a5ef1 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/TextBoxTests.cs @@ -10,7 +10,7 @@ namespace Aquality.Selenium.Tests.Integration.Elements { internal class TextBoxTests : UITest { - private readonly AuthenticationForm authForm = new AuthenticationForm(); + private readonly AuthenticationForm authForm = new(); [SetUp] public void BeforeTest() @@ -24,7 +24,7 @@ public void Should_BePossibleTo_FocusAndType() var text = "wrong"; var usernameTxb = authForm.UserNameTextBox; usernameTxb.Type(text); - Assert.AreEqual(text, usernameTxb.Value); + Assert.That(usernameTxb.Value, Is.EqualTo(text)); } [Test] @@ -35,7 +35,7 @@ public void Should_BePossibleTo_ClearAndType() var usernameTxb = authForm.UserNameTextBox; usernameTxb.Type(initialText); usernameTxb.ClearAndType(targetText); - Assert.AreEqual(targetText, usernameTxb.Value); + Assert.That(usernameTxb.Value, Is.EqualTo(targetText)); } [Test] @@ -43,7 +43,7 @@ public void Should_BePossibleTo_SendKey() { var passwordTxb = authForm.PasswordTextBox; passwordTxb.SendKey(Key.NumberPad0); - Assert.AreEqual("0", passwordTxb.Value); + Assert.That(passwordTxb.Value, Is.EqualTo("0")); } [Test] @@ -51,7 +51,7 @@ public void Should_BePossibleTo_SendKeys() { var passwordTxb = authForm.PasswordTextBox; passwordTxb.SendKeys("00"); - Assert.AreEqual("00", passwordTxb.Value); + Assert.That(passwordTxb.Value, Is.EqualTo("00")); } [Test] @@ -59,7 +59,7 @@ public void Should_BePossibleTo_Submit() { var passwordTxb = authForm.PasswordTextBox; passwordTxb.Submit(); - Assert.IsTrue(AqualityServices.ConditionalWait.WaitFor(() => passwordTxb.Value.Equals("", StringComparison.OrdinalIgnoreCase))); + Assert.That(AqualityServices.ConditionalWait.WaitFor(() => passwordTxb.Value.Equals("", StringComparison.OrdinalIgnoreCase))); } [Test] @@ -72,8 +72,8 @@ public void Should_BePossibleTo_SetInnerHtml() Assert.Multiple(() => { - Assert.IsTrue(usernameTxb.State.WaitForNotExist()); - Assert.IsTrue(authForm.GetCustomElementBasedOnLoginLabel("/p[.='123123']").State.WaitForDisplayed()); + Assert.That(usernameTxb.State.WaitForNotExist()); + Assert.That(authForm.GetCustomElementBasedOnLoginLabel("/p[.='123123']").State.WaitForDisplayed()); }); } @@ -85,8 +85,8 @@ public void Should_BePossibleTo_GetCssValue() var usernameTxb = authForm.UserNameTextBox; Assert.Multiple(() => { - Assert.IsTrue(usernameTxb.GetCssValue(propertyName).Contains(expectedCssValue)); - Assert.IsTrue(usernameTxb.GetCssValue(propertyName, HighlightState.Highlight).Contains(expectedCssValue)); + Assert.That(usernameTxb.GetCssValue(propertyName).Contains(expectedCssValue)); + Assert.That(usernameTxb.GetCssValue(propertyName, HighlightState.Highlight).Contains(expectedCssValue)); }); } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/HiddenElementsTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/HiddenElementsTests.cs index 94802e76..bf23d5ae 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/HiddenElementsTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/HiddenElementsTests.cs @@ -11,7 +11,7 @@ namespace Aquality.Selenium.Tests.Integration { internal class HiddenElementsTests : UITest { - private static readonly HoversForm hoversForm = new HoversForm(); + private static readonly HoversForm hoversForm = new(); private static readonly Func>[] ElementListProviders = new Func>[] @@ -34,7 +34,7 @@ public void BeforeTest() [Test] public void Should_BePossibleTo_CheckThatHiddenElementExists() { - Assert.IsTrue(HoversForm.GetHiddenElement(HoverExample.First, ElementState.ExistsInAnyState).State.IsExist); + Assert.That(HoversForm.GetHiddenElement(HoverExample.First, ElementState.ExistsInAnyState).State.IsExist); } [Test] @@ -44,8 +44,8 @@ public void Should_BePossibleTo_CheckThatHiddenElementsExist( var elements = elementListProvider(ElementState.ExistsInAnyState, ElementsCount.MoreThenZero); Assert.Multiple(() => { - Assert.IsTrue(elements.Any()); - Assert.IsTrue(elements.All(element => element.State.WaitForExist())); + Assert.That(elements.Any()); + Assert.That(elements.All(element => element.State.WaitForExist())); }); } @@ -56,8 +56,8 @@ public void Should_BePossibleTo_CheckThatHiddenElementsNotDisplayed( var elements = elementListProvider(ElementState.ExistsInAnyState, ElementsCount.MoreThenZero); Assert.Multiple(() => { - Assert.IsTrue(elements.Any()); - Assert.IsTrue(elements.All(element => + Assert.That(elements.Any()); + Assert.That(elements.All(element => { var result = element.State.WaitForNotDisplayed(); if (!result) diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs index 877e72c0..adfe3c83 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs @@ -8,7 +8,7 @@ namespace Aquality.Selenium.Tests.Integration { internal class ImageLocatorTests : UITest { - private readonly BrokenImagesForm form = new BrokenImagesForm(); + private readonly BrokenImagesForm form = new(); [Test] public void Should_BePossibleTo_FindByImage() diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/JavaScriptHandlingTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/JavaScriptHandlingTests.cs index c0399250..47e54a8b 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/JavaScriptHandlingTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/JavaScriptHandlingTests.cs @@ -33,15 +33,15 @@ public void Should_BePossibleTo_SubscribeToDomMutationEvent_AndUnsubscribeFromIt welcomeForm.SubTitleLabel.JsActions.SetAttribute(attributeName, attributeValue); AqualityServices.ConditionalWait.WaitForTrue(() => attributeValueChanges.Count > 0, message: "Some mutation events should be found, should be possible to subscribe to DOM mutation event"); - Assert.AreEqual(1, attributeValueChanges.Count, "Exactly one change in DOM is expected"); + Assert.That(attributeValueChanges.Count, Is.EqualTo(1), "Exactly one change in DOM is expected"); var record = attributeValueChanges.Single(); - Assert.AreEqual(attributeName, record.AttributeName, "Attribute name should match to expected"); - Assert.AreEqual(attributeValue, record.AttributeValue, "Attribute value should match to expected"); + Assert.That(record.AttributeName, Is.EqualTo(attributeName), "Attribute name should match to expected"); + Assert.That(record.AttributeValue, Is.EqualTo(attributeValue), "Attribute value should match to expected"); JavaScriptEngine.DomMutated -= eventHandler; welcomeForm.SubTitleLabel.JsActions.SetAttribute(attributeName, attributeName); AqualityServices.ConditionalWait.WaitFor(() => attributeValueChanges.Count > 1, timeout: NegativeConditionTimeout); - Assert.AreEqual(1, attributeValueChanges.Count, "No more changes in DOM is expected, should be possible to unsubscribe from DOM mutation event"); + Assert.That(attributeValueChanges.Count, Is.EqualTo(1), "No more changes in DOM is expected, should be possible to unsubscribe from DOM mutation event"); Assert.DoesNotThrowAsync(async () => await JavaScriptEngine.DisableDomMutationMonitoring(), "Should be possible to disable DOM mutation monitoring"); Assert.DoesNotThrow(() => JavaScriptEngine.StopEventMonitoring(), "Should be possible to stop event monitoring"); @@ -57,9 +57,9 @@ public void Should_BePossibleTo_PinScript_AndUnpinIt() welcomeForm.Open(); var xpath = pinnedScript.ExecuteScript(welcomeForm.SubTitleLabel); - Assert.IsNotEmpty(xpath, "Pinned script should be possible to execute"); + Assert.That(xpath, Is.Not.Empty, "Pinned script should be possible to execute"); var expectedValue = welcomeForm.SubTitleLabel.JsActions.GetXPath(); - Assert.AreEqual(expectedValue, xpath, "Pinned script should return the same value"); + Assert.That(xpath, Is.EqualTo(expectedValue), "Pinned script should return the same value"); Assert.DoesNotThrowAsync(async () => await JavaScriptEngine.UnpinScript(pinnedScript), "Should be possible to unpin the script"); Assert.Throws( @@ -81,7 +81,7 @@ public void Should_BePossibleTo_PinScript_WithoutReturnedValue_AndUnpinIt() Assert.DoesNotThrow(() => pinnedScript.ExecuteScript(keyPressesForm.InputTextBox, text), "Should be possible to execute pinned script without return value"); var actualText = keyPressesForm.InputTextBox.Value; - Assert.AreEqual(text, actualText, $"Text should be '{text}' after setting value via pinned JS"); + Assert.That(actualText, Is.EqualTo(text), $"Text should be '{text}' after setting value via pinned JS"); Assert.DoesNotThrowAsync(async () => await JavaScriptEngine.UnpinScript(pinnedScript), "Should be possible to unpin the script"); Assert.Throws(() => pinnedScript.ExecuteScript(keyPressesForm.InputTextBox, text), "Unpinned script should not be executed"); @@ -105,7 +105,7 @@ public void Should_BePossibleTo_SubscribeToJavaScriptConsoleApiCalledEvent_AndUn JavaScriptEngine.JavaScriptConsoleApiCalled -= eventHandler; AqualityServices.Browser.ExecuteScript(consoleApiScript); AqualityServices.ConditionalWait.WaitFor(() => apiCalledMessages.Count > previousCount, timeout: NegativeConditionTimeout); - Assert.AreEqual(previousCount, apiCalledMessages.Count, "No more JS console API events should be recorded, should be possible to unsubscribe from JS Console API called event"); + Assert.That(apiCalledMessages.Count, Is.EqualTo(previousCount), "No more JS console API events should be recorded, should be possible to unsubscribe from JS Console API called event"); } [Test] @@ -126,7 +126,7 @@ public void Should_BePossibleTo_SubscribeToJavaScriptExceptionThrownEvent_AndUns JavaScriptEngine.JavaScriptExceptionThrown -= eventHandler; welcomeForm.SubTitleLabel.Click(); AqualityServices.ConditionalWait.WaitFor(() => errorMessages.Count > previousCount, timeout: NegativeConditionTimeout); - Assert.AreEqual(previousCount, errorMessages.Count, "No more JS exceptions should be recorded, should be possible to unsubscribe from JS Exceptions thrown event"); + Assert.That(errorMessages.Count, Is.EqualTo(previousCount), "No more JS exceptions should be recorded, should be possible to unsubscribe from JS Exceptions thrown event"); } [Test] @@ -136,9 +136,9 @@ public void Should_BePossibleTo_AddInitializationScript_GetIt_ThenRemove_OrClear const string name = "alert"; InitializationScript initScript = null; Assert.DoesNotThrowAsync(async () => initScript = await JavaScriptEngine.AddInitializationScript(name, script), "Should be possible to add initialization script"); - Assert.IsNotNull(initScript, "Some initialization script model should be returned"); - Assert.AreEqual(script, initScript.ScriptSource, "Saved script source should match to expected"); - Assert.AreEqual(name, initScript.ScriptName, "Saved script name should match to expected"); + Assert.That(initScript, Is.Not.Null, "Some initialization script model should be returned"); + Assert.That(initScript.ScriptSource, Is.EqualTo(script), "Saved script source should match to expected"); + Assert.That(initScript.ScriptName, Is.EqualTo(name), "Saved script name should match to expected"); Assert.DoesNotThrowAsync(async() => await JavaScriptEngine.StartEventMonitoring(), "Should be possible to start event monitoring"); AqualityServices.Browser.Refresh(); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/NetworkHandlingTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/NetworkHandlingTests.cs index 982d2d6f..c0cdf4ab 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/NetworkHandlingTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/NetworkHandlingTests.cs @@ -20,7 +20,7 @@ public void Should_BePossibleTo_SetBasicAuthentication() Assert.DoesNotThrowAsync(async () => await AqualityServices.Browser.RegisterBasicAuthenticationAndStartMonitoring(BasicAuthForm.Domain, BasicAuthForm.User, BasicAuthForm.Password), "Should be possible to set basic authentication async"); basicAuthForm.Open(); - Assert.IsTrue(basicAuthForm.IsCongratulationsPresent, "Basic authentication should work"); + Assert.That(basicAuthForm.IsCongratulationsPresent, "Basic authentication should work"); } [Test] @@ -33,7 +33,7 @@ public void Should_BePossibleTo_ClearBasicAuthentication() "Should be possible to set basic authentication async"); AqualityServices.Browser.Network.ClearAuthenticationHandlers(); basicAuthForm.Open(); - Assert.IsFalse(basicAuthForm.IsCongratulationsPresent, "Basic authentication should not work after the handler is cleared"); + Assert.That(basicAuthForm.IsCongratulationsPresent, Is.False, "Basic authentication should not work after the handler is cleared"); Assert.DoesNotThrowAsync(async () => await AqualityServices.Browser.Network.StopMonitoring(), "Should be possible to stop network monitoring"); } @@ -50,10 +50,10 @@ public void Should_BePossibleTo_AddAndClearRequestHandler() Assert.DoesNotThrowAsync(() => AqualityServices.Browser.Network.StartMonitoring()); var welcomeForm = new WelcomeForm(); welcomeForm.Open(); - StringAssert.Contains(somePhrase, AqualityServices.Browser.Driver.PageSource, "Request should be intercepted"); + Assert.That(AqualityServices.Browser.Driver.PageSource, Does.Contain(somePhrase), "Request should be intercepted"); AqualityServices.Browser.Network.ClearRequestHandlers(); welcomeForm.Open(); - StringAssert.DoesNotContain(somePhrase, AqualityServices.Browser.Driver.PageSource, "Request should not be intercepted"); + Assert.That(AqualityServices.Browser.Driver.PageSource, Does.Not.Contain(somePhrase), "Request should not be intercepted"); } [Test] @@ -69,10 +69,10 @@ public void Should_BePossibleTo_AddAndClearResponseHandler() Assert.DoesNotThrowAsync(async() => await AqualityServices.Browser.Network.StartMonitoring()); var welcomeForm = new WelcomeForm(); welcomeForm.Open(); - StringAssert.Contains(somePhrase, AqualityServices.Browser.Driver.PageSource, "Response should be intercepted"); + Assert.That(AqualityServices.Browser.Driver.PageSource, Does.Contain(somePhrase), "Response should be intercepted"); AqualityServices.Browser.Network.ClearResponseHandlers(); welcomeForm.Open(); - StringAssert.DoesNotContain(somePhrase, AqualityServices.Browser.Driver.PageSource, "Response should not be intercepted"); + Assert.That(AqualityServices.Browser.Driver.PageSource, Does.Not.Contain(somePhrase), "Response should not be intercepted"); } [Test] @@ -89,7 +89,7 @@ public void Should_BePossibleTo_SubscribeToRequestSentEvent_AndUnsubscribeFromIt var oldValue = counter; AqualityServices.Browser.Network.NetworkRequestSent -= eventHandler; welcomeForm.Open(); - Assert.AreEqual(oldValue, counter, "Should be possible to unsubscribe from Request Sent event"); + Assert.That(counter, Is.EqualTo(oldValue), "Should be possible to unsubscribe from Request Sent event"); } [Test] @@ -106,7 +106,7 @@ public void Should_BePossibleTo_SubscribeToResponseReceivedEvent_AndUnsubscribeF var oldValue = counter; AqualityServices.Browser.Network.NetworkResponseReceived -= eventHandler; welcomeForm.Open(); - Assert.AreEqual(oldValue, counter, "Should be possible to unsubscribe from Response Received event"); + Assert.That(counter, Is.EqualTo(oldValue), "Should be possible to unsubscribe from Response Received event"); } [Test] @@ -116,12 +116,12 @@ public void Should_BePossibleTo_EnableHttpExchangeLogging_AndDisableIt() var someForm = new DropdownForm(); someForm.Open(); var logMessage1 = File.ReadAllLines(LogPath).LastOrDefault(); - Assert.IsFalse(string.IsNullOrEmpty(logMessage1), "Some message should appear in log file and should not be empty"); + Assert.That(string.IsNullOrEmpty(logMessage1), Is.False, "Some message should appear in log file and should not be empty"); Assert.DoesNotThrowAsync(async () => await AqualityServices.Browser.EnableHttpExchangeLoggingAndStartMonitoring(), "Should be possible to enable HTTP exchange logging"); AqualityServices.Browser.Driver.Navigate().Refresh(); var logMessage2 = File.ReadAllLines(LogPath).LastOrDefault(); - Assert.IsFalse(string.IsNullOrEmpty(logMessage2), "Some message should appear in log file and should not be empty"); - Assert.AreNotEqual(logMessage1, logMessage2, "HTTP logging message should be in file, although no Aquality-actions performed"); + Assert.That(string.IsNullOrEmpty(logMessage2), Is.False, "Some message should appear in log file and should not be empty"); + Assert.That(logMessage2, Is.Not.EqualTo(logMessage1), "HTTP logging message should be in file, although no Aquality-actions performed"); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ShadowRootTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ShadowRootTests.cs index 599fff58..7bafc7a8 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ShadowRootTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ShadowRootTests.cs @@ -7,7 +7,7 @@ namespace Aquality.Selenium.Tests.Integration { internal class ShadowRootTests : UITest { - private static readonly ChromeDownloadsForm form = new ChromeDownloadsForm(); + private static readonly ChromeDownloadsForm form = new(); [SetUp] public void OpenDownloads() @@ -18,16 +18,16 @@ public void OpenDownloads() [Test] public void Should_ExpandShadowRoot_FromElement() { - Assert.IsNotNull(form.ExpandShadowRoot(), "Should be possible to expand shadow root and get Selenium native ShadowRoot object"); + Assert.That(form.ExpandShadowRoot(), Is.Not.Null, "Should be possible to expand shadow root and get Selenium native ShadowRoot object"); } [Test] public void Should_BePossibleTo_FindElement_InShadowRoot() { - Assert.IsNotNull(form.DownloadsToolbarLabel.GetElement(), "Should be possible do get the element hidden under the shadow"); - Assert.IsNotNull(form.DownloadsToolbarLabel.FindElementInShadowRoot(ChromeDownloadsForm.NestedShadowRootLocator, "More actions menu").GetElement(), + Assert.That(form.DownloadsToolbarLabel.GetElement(), Is.Not.Null, "Should be possible do get the element hidden under the shadow"); + Assert.That(form.DownloadsToolbarLabel.FindElementInShadowRoot(ChromeDownloadsForm.NestedShadowRootLocator, "More actions menu").GetElement(), Is.Not.Null, "Should be possible to expand the nested shadow root and get the element from it"); - Assert.IsTrue(form.MainContainerLabel.State.IsDisplayed, "Should be possible to check that element under the shadow is displayed"); + Assert.That(form.MainContainerLabel.State.IsDisplayed, "Should be possible to check that element under the shadow is displayed"); } [Test] @@ -43,16 +43,15 @@ public void Should_BePossibleTo_FindElements_InShadowRoot() [Test] public void ShouldBePossibleTo_ExpandShadowRoot_ViaJs() { - Assert.IsNotNull(form.ExpandShadowRootViaJs(), "Should be possible to expand shadow root and get Selenium native ShadowRoot object"); - Assert.IsNotNull(form.DownloadsToolbarLabelFromJs.GetElement(), "Should be possible do get the element hidden under the shadow"); + Assert.That(form.ExpandShadowRootViaJs(), Is.Not.Null, "Should be possible to expand shadow root and get Selenium native ShadowRoot object"); + Assert.That(form.DownloadsToolbarLabelFromJs.GetElement(), Is.Not.Null, "Should be possible do get the element hidden under the shadow"); var elementLabels = form.DivElementLabelsFromJs; Assert.That(elementLabels, Has.Count.GreaterThan(1), "Should be possible to find multiple elements hidden under the shadow"); Assert.That(elementLabels.First().Locator.Mechanism, Contains.Substring("css"), "Unique locator of correct type should be generated"); Assert.That(elementLabels.First().GetElement().TagName, Is.EqualTo("div"), "Should be possible to work with one of found elements"); Assert.That(form.MainContainerLabelsFromJs.First().GetElement().TagName, Is.EqualTo("div"), "Should be possible to work with one of found elements found by id"); - Assert.IsNotNull(form.DownloadsToolbarLabelFromJs.JsActions.FindElementInShadowRoot(ChromeDownloadsForm.NestedShadowRootLocator, "More actions menu").GetElement(), - "Should be possible to expand the nested shadow root and get the element from it"); - Assert.IsTrue(form.MainContainerLabelFromJs.State.IsDisplayed, "Should be possible to check that element under the shadow is displayed"); + Assert.That(form.DownloadsToolbarLabelFromJs.JsActions.FindElementInShadowRoot(ChromeDownloadsForm.NestedShadowRootLocator, "More actions menu").GetElement(), Is.Not.Null, "Should be possible to expand the nested shadow root and get the element from it"); + Assert.That(form.MainContainerLabelFromJs.State.IsDisplayed, "Should be possible to check that element under the shadow is displayed"); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs index 552283f2..0f2b083a 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductListForm.cs @@ -12,7 +12,7 @@ namespace Aquality.Selenium.Tests.Integration.TestApp.AutomationPractice.Forms { internal class ProductListForm : Form { - private readonly Random random = new Random(); + private readonly Random random = new(); private const string FormLocator = "//ul[@id='homefeatured']"; diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/MyLocation/LocationForm.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/MyLocation/LocationForm.cs index c25cdf14..2104bcb6 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/MyLocation/LocationForm.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/MyLocation/LocationForm.cs @@ -14,7 +14,7 @@ internal class LocationForm : Form private readonly IButton browserGeoLocationButton = ElementFactory.GetButton(By.XPath("//*[@aria-controls='geo-div']"), "Browser GeoLocation"); private readonly IButton startTestButton = ElementFactory.GetButton(By.Id("geo-test"), "Browser GeoLocation"); private readonly IButton consentCookieInfoButton = ElementFactory.GetButton(By.XPath("//button[contains(@aria-label,'Consent')]"), "Consent cookie info"); - private readonly IButton gotItCookieButton = ElementFactory.GetButton(By.XPath("//a[contains(@aria-label,'dismiss')]"), "Got it! for Google cookie"); + private readonly IButton gotItCookieButton = ElementFactory.GetButton(By.XPath("//a[contains(@aria-label,'dismiss')] | //img[contains(@src,'close')]"), "Got it! for Google cookie"); private readonly IButton closeCookieSettingsButton = ElementFactory.GetButton(By.XPath("//*[contains(@class,'google-revocation-link')]//*[contains(@src,'close') or contains(@aria-label, 'lose')]"), "Close cookie settings"); public LocationForm() : base(By.Id("accordion"), "My Location") @@ -25,8 +25,11 @@ public void DismissCookieInfo() { consentCookieInfoButton.Click(); consentCookieInfoButton.State.WaitForNotDisplayed(); - gotItCookieButton.Click(); - gotItCookieButton.State.WaitForNotDisplayed(); + if (gotItCookieButton.State.WaitForDisplayed()) + { + gotItCookieButton.Click(); + gotItCookieButton.State.WaitForNotDisplayed(); + } if (closeCookieSettingsButton.State.IsDisplayed) { closeCookieSettingsButton.Click(); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/BrowserConcurrencyTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/BrowserConcurrencyTests.cs index 8d0c43a1..ca0e0784 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/BrowserConcurrencyTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/BrowserConcurrencyTests.cs @@ -14,14 +14,14 @@ public void Should_BePossibleTo_CreateDifferentBrowsersInDifferentThreads() { var checkBoxesForm = new CheckBoxesForm(); checkBoxesForm.Open(); - Assert.AreEqual(checkBoxesForm.Url, AqualityServices.Browser.CurrentUrl); + Assert.That(AqualityServices.Browser.CurrentUrl, Is.EqualTo(checkBoxesForm.Url)); AqualityServices.Browser.Quit(); }); var thread02 = new Thread(() => { var authForm = new AuthenticationForm(); authForm.Open(); - Assert.AreEqual(authForm.Url, AqualityServices.Browser.CurrentUrl); + Assert.That(AqualityServices.Browser.CurrentUrl, Is.EqualTo(authForm.Url)); AqualityServices.Browser.Quit(); }); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs index eac78901..d96341d6 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomBrowserFactoryTests.cs @@ -1,12 +1,10 @@ using Aquality.Selenium.Browsers; using Aquality.Selenium.Configurations; -using Aquality.Selenium.Configurations.WebDriverSettings; using NUnit.Framework; using OpenQA.Selenium.Chrome; using System; using WebDriverManager; using WebDriverManager.DriverConfigs.Impl; -using WebDriverManager.DriverConfigs; using WebDriverManager.Helpers; using System.IO; using Aquality.Selenium.Core.Utilities; @@ -26,7 +24,7 @@ public void Should_BePossibleToUse_BrowserFromCustomFactory() var browserFactory = new CustomLocalBrowserFactory(); AqualityServices.Browser = browserFactory.Browser; AqualityServices.Browser.GoTo(url); - Assert.AreEqual(url, AqualityServices.Browser.CurrentUrl); + Assert.That(AqualityServices.Browser.CurrentUrl, Is.EqualTo(url)); } [Test] @@ -35,7 +33,7 @@ public void Should_BePossibleToUse_CustomFactory() var browserFactory = new CustomLocalBrowserFactory(); AqualityServices.BrowserFactory = browserFactory; AqualityServices.Browser.GoTo(url); - Assert.AreEqual(url, AqualityServices.Browser.CurrentUrl); + Assert.That(AqualityServices.Browser.CurrentUrl, Is.EqualTo(url)); } [TearDown] @@ -47,7 +45,7 @@ public void TearDown() public class CustomLocalBrowserFactory : BrowserFactory { - private static readonly object WebDriverDownloadingLock = new object(); + private static readonly object WebDriverDownloadingLock = new(); public CustomLocalBrowserFactory() : base(AqualityServices.Get(), AqualityServices.Get(), AqualityServices.Get(), AqualityServices.LocalizedLogger) @@ -59,12 +57,12 @@ protected override WebDriver Driver get { var driverSettings = BrowserProfile.DriverSettings; - SetUpDriver(new ChromeConfig(), driverSettings); + SetUpDriver(new()); return new ChromeDriver((ChromeOptions)driverSettings.DriverOptions); } } - private static void SetUpDriver(IDriverConfig driverConfig, IDriverSettings driverSettings) + private static void SetUpDriver(ChromeConfig driverConfig) { var architecture = ArchitectureHelper.GetArchitecture(); var version = driverConfig.GetMatchingBrowserVersion(); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomElementTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomElementTests.cs index 6e05ff4b..6a2bd042 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomElementTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/CustomElementTests.cs @@ -18,7 +18,7 @@ public void ShouldBe_PossibleTo_CreateCustomTextBox() var userNameCustomTxb = new CustomTextBox(userNameTxb.Locator, userNameTxb.Name); userNameTxb.Type("wrong"); userNameCustomTxb.Type("right"); - Assert.AreEqual(userNameTxb.Value, userNameCustomTxb.Text); + Assert.That(userNameCustomTxb.Text, Is.EqualTo(userNameTxb.Value)); } private class CustomTextBox : TextBox diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ElementExistsButNotDisplayedTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ElementExistsButNotDisplayedTests.cs index fda2eff8..91083668 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ElementExistsButNotDisplayedTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ElementExistsButNotDisplayedTests.cs @@ -10,7 +10,7 @@ namespace Aquality.Selenium.Tests.Integration.Usecases { internal class ElementExistsButNotDisplayedTests : UITest { - private static readonly HoversForm hoversForm = new HoversForm(); + private static readonly HoversForm hoversForm = new(); private readonly By fakeElement = By.XPath("//fake"); private readonly TimeSpan smallTimeout = TimeSpan.FromSeconds(1); @@ -24,7 +24,7 @@ public void BeforeTest() public void Should_BePossibleTo_WaitForElement_WhichExistsButNotDisplayed() { var button = HoversForm.GetHiddenElement(HoverExample.First, ElementState.ExistsInAnyState); - Assert.IsTrue(AqualityServices.ConditionalWait.WaitFor(() => button.State.IsExist && !button.State.IsDisplayed)); + Assert.That(AqualityServices.ConditionalWait.WaitFor(() => button.State.IsExist && !button.State.IsDisplayed)); } [Test] diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs index 712e141b..4ced18e1 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/FileDownloadingTests.cs @@ -22,7 +22,7 @@ public void Should_BePossibleTo_DownloadTextFile() FileDownloadHelper.DeleteFileIfExist(filePath); var lblFileContent = AqualityServices.Get().GetLabel(By.XPath("//pre"), "text file content"); - Assert.False(FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent), $"file {filePath} should not exist before downloading"); + Assert.That(FileDownloadHelper.IsFileDownloaded(filePath, lblFileContent), Is.False, $"file {filePath} should not exist before downloading"); var oldWindowHandle = browser.Tabs().CurrentTabHandle; browser.ExecuteScriptFromFile("Resources.OpenUrlInNewWindow.js", downloaderForm.Url); diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs index 99c07a97..ac985910 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/ShoppingCartTests.cs @@ -40,12 +40,12 @@ private void ActionsOnAutomationPractice() SiteLoader.OpenAutomationPracticeSite(); AqualityServices.Browser.Maximize(); var sliderForm = new SliderForm(); - Assert.IsTrue(sliderForm.State.WaitForDisplayed(), "Slider Form is not opened"); + Assert.That(sliderForm.State.WaitForDisplayed(), "Slider Form is not opened"); sliderForm.ClickNextButton(); sliderForm.ClickNextButton(); var productListForm = new ProductListForm(); - Assert.AreEqual(ExpectedNumdberOfProducts, productListForm.GetNumberOfProductsInContainer(), "Number of products is incorrect"); + Assert.That(productListForm.GetNumberOfProductsInContainer(), Is.EqualTo(ExpectedNumdberOfProducts), "Number of products is incorrect"); productListForm.AddRandomProductToCart(); var proceedToCheckoutModal = new ProceedToCheckoutModal(); @@ -53,11 +53,11 @@ private void ActionsOnAutomationPractice() var shoppingCardSummaryForm = new ShoppingCardSummaryForm(); shoppingCardSummaryForm.ClickPlusButton(); var actualQuantity = shoppingCardSummaryForm.WaitForQuantityAndGetValue(ExpectedQuantity); - Assert.AreEqual(ExpectedQuantity, actualQuantity, "Quantity is incorrect"); + Assert.That(actualQuantity, Is.EqualTo(ExpectedQuantity), "Quantity is incorrect"); shoppingCardSummaryForm.ClickProceedToCheckoutButton(); var authForm = new AuthenticationForm(); - Assert.IsTrue(authForm.State.WaitForDisplayed(), "Authentication Form is not opened"); + Assert.That(authForm.State.WaitForDisplayed(), "Authentication Form is not opened"); var cartMenuForm = new CartMenuForm(); cartMenuForm.OpenCartMenu(); @@ -71,14 +71,14 @@ private void ActionsOnAutomationPractice() personalInfoForm.SelectGender(Gender); personalInfoForm.SetFirstName(FirstName); var actualNumberOfDays = personalInfoForm.GetNumberOfDays(); - Assert.AreEqual(ExpectedNumberOfDays, actualNumberOfDays, "Number of days from combobox is incorrect"); + Assert.That(actualNumberOfDays, Is.EqualTo(ExpectedNumberOfDays), "Number of days from combobox is incorrect"); personalInfoForm.SelectState(State); personalInfoForm.SelectDay(DayToSelect); - Assert.IsFalse(personalInfoForm.IsNewsCheckBoxChecked(), "News checkbox state is not correct"); + Assert.That(personalInfoForm.IsNewsCheckBoxChecked(), Is.False, "News checkbox state is not correct"); personalInfoForm.SetNewsCheckBox(); - Assert.IsTrue(personalInfoForm.IsNewsCheckBoxChecked(), "News checkbox state is not correct"); + Assert.That(personalInfoForm.IsNewsCheckBoxChecked(), "News checkbox state is not correct"); } } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/VisualTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/VisualTests.cs index 797724b1..96918d14 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/VisualTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Usecases/VisualTests.cs @@ -6,7 +6,7 @@ namespace Aquality.Selenium.Tests.Integration.Usecases { internal class VisualTests : UITest { - private static readonly DynamicContentForm dynamicContentForm = new DynamicContentForm(); + private static readonly DynamicContentForm dynamicContentForm = new(); [SetUp] public void BeforeTest() diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs index 6804865f..ac4d3f72 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/AqualityServicesTests.cs @@ -18,14 +18,14 @@ public void Should_BeAbleGetBrowser() [Test] public void Should_BeAbleCheck_IsBrowserNotStarted() { - Assert.IsFalse(AqualityServices.IsBrowserStarted, "Browser is not started"); + Assert.That(AqualityServices.IsBrowserStarted, Is.False, "Browser is not started"); } [Test] public void Should_BeAbleCheck_IsBrowserStarted() { AqualityServices.Browser.WaitForPageToLoad(); - Assert.IsTrue(AqualityServices.IsBrowserStarted, "Browser is started"); + Assert.That(AqualityServices.IsBrowserStarted, "Browser is started"); } [Test] @@ -83,7 +83,7 @@ public void Should_BeAbleToCreateLocalBrowser(BrowserName browserName) Environment.SetEnvironmentVariable("browserName", browserName.ToString()); Environment.SetEnvironmentVariable("isRemote", "false"); Assert.DoesNotThrow(() => AqualityServices.Browser.WaitForPageToLoad()); - Assert.AreEqual(AqualityServices.Browser.BrowserName, browserName); + Assert.That(browserName, Is.EqualTo(AqualityServices.Browser.BrowserName)); } [TearDown] diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/Configuration/CustomConfigurationTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/Configuration/CustomConfigurationTests.cs index 7704b20d..2588d41c 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/Configuration/CustomConfigurationTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/Configuration/CustomConfigurationTests.cs @@ -24,19 +24,19 @@ public static void Before() [Test] public void Should_BeAbleOverrideDependencies_AndGetCustomService() { - Assert.AreEqual(SpecialLoggerLanguage, AqualityServices.Get().Language, "Configuration value should be overriden."); + Assert.That(AqualityServices.Get().Language, Is.EqualTo(SpecialLoggerLanguage), "Configuration value should be overriden."); } [Test] public void Should_BeAbleAdd_CustomService() { - Assert.AreEqual(SpecialCustomValue, AqualityServices.Get().CustomValue, "Custom service should have value"); + Assert.That(AqualityServices.Get().CustomValue, Is.EqualTo(SpecialCustomValue), "Custom service should have value"); } [Test] public void Should_BeAbleGet_DefaultService() { - Assert.AreEqual(DefaultCommandTimeout, AqualityServices.Get().Command, "Default service value should have default value"); + Assert.That(AqualityServices.Get().Command, Is.EqualTo(DefaultCommandTimeout), "Default service value should have default value"); } [TearDown] diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/JavaScriptTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/JavaScriptTests.cs index fc711c2b..dfca645d 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/JavaScriptTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/JavaScriptTests.cs @@ -9,21 +9,20 @@ namespace Aquality.Selenium.Tests.Unit [Parallelizable(ParallelScope.All)] internal class JavaScriptTests { -#pragma warning disable IDE0052 // Remove unread private members private static readonly JavaScript[] JavaScripts = Enum.GetValues(typeof(JavaScript)) as JavaScript[]; -#pragma warning restore IDE0052 // Remove unread private members [TestCaseSource("JavaScripts")] public void Should_GetJavaScript(JavaScript script) { - Assert.IsNotEmpty(script.GetScript(), $"Failed to get javascript {script}"); + Assert.That(script.GetScript(), Is.Not.Empty, $"Failed to get javascript {script}"); } [Test] public void Should_BeUniqueJavaScripts() { - Assert.IsEmpty( + Assert.That( JavaScripts.GroupBy(script => script.GetScript()).Where(group => group.Count() > 1).Select(group => string.Join(" and ", group)), + Is.Empty, "some duplicates where found among JavaScripts"); } } diff --git a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs index c336a1e4..4faebe13 100644 --- a/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs +++ b/Aquality.Selenium/tests/Aquality.Selenium.Tests/Unit/LocalizationManagerTests.cs @@ -48,8 +48,8 @@ public void Should_BeAble_LogLocalizedMessage(LogLevel logLevel) } var logMessage = File.ReadAllLines(LogPath).LastOrDefault(); - Assert.IsFalse(string.IsNullOrEmpty(logMessage), "Message should appear in log file"); - Assert.IsTrue(logMessage.Contains(LocalizedNavigationMessage), + Assert.That(string.IsNullOrEmpty(logMessage), Is.False, "Message should appear in log file"); + Assert.That(logMessage.Contains(LocalizedNavigationMessage), $"Message should be localized. Expected: {LocalizedNavigationMessage}, actual: {logMessage}"); } @@ -57,7 +57,7 @@ public void Should_BeAble_LogLocalizedMessage(LogLevel logLevel) public void Should_BeAble_ToLocalizeLoggerMessage() { var message = LocalizationManager.GetLocalizedMessage("loc.browser.navigate", "test"); - Assert.AreEqual(LocalizedNavigationMessage, message, "Message should be localized"); + Assert.That(message, Is.EqualTo(LocalizedNavigationMessage), "Message should be localized"); } public enum LogLevel diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 45946920..536a6b66 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,7 +2,7 @@ trigger: - master pool: - vmImage: 'windows-2019' + vmImage: 'windows-latest' variables: buildConfiguration: 'Release' @@ -26,12 +26,6 @@ stages: extraProperties: | sonar.coverage.exclusions=**/** - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.0.x' - - task: DotNetCoreCLI@2 displayName: 'Build solution' env: @@ -54,13 +48,7 @@ stages: variables: profile: 'azure' - steps: - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.0.x' - + steps: - task: DotNetCoreCLI@2 displayName: 'Run tests' retryCountOnTaskFailure: 1 @@ -86,13 +74,7 @@ stages: inputs: useConfigFile: true configFilePath: 'GitVersion.yml' - - - task: UseDotNet@2 - displayName: Use .NET 6.0 - inputs: - packageType: 'sdk' - version: '6.0.x' - + - script: dotnet pack Aquality.Selenium\src\Aquality.Selenium\Aquality.Selenium.csproj -c $(buildConfiguration) -p:Version=$(GitVersion.NuGetVersion) -o $(Build.ArtifactStagingDirectory) displayName: 'Pack to NuGet package'