Skip to content

Commit

Permalink
[dotnet] Fixing SelectTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Mar 23, 2024
1 parent 65b5ff3 commit 3c74f07
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions dotnet/test/support/UI/SelectTests.cs
Expand Up @@ -109,6 +109,7 @@ public void CanSetSingleOptionSelectedByText()
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();

Expand All @@ -128,6 +129,7 @@ public void CanSetSingleOptionSelectedByValue()
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();

Expand All @@ -148,6 +150,7 @@ public void CanSetSingleOptionSelectedByIndex()
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();

Expand All @@ -170,8 +173,10 @@ public void CanSetMultipleOptionSelectedByText()
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
option2.SetupGet<bool>(_ => _.Selected).Returns(false);
option2.SetupGet<bool>(_ => _.Enabled).Returns(true);
option2.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();

Expand All @@ -195,8 +200,10 @@ public void CanSetMultipleOptionSelectedByValue()
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
option2.SetupGet<bool>(_ => _.Selected).Returns(false);
option2.SetupGet<bool>(_ => _.Enabled).Returns(true);
option2.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();

Expand All @@ -219,17 +226,19 @@ public void CanSetMultipleOptionSelectedByIndex()

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("1");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
option2.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
option2.SetupGet<bool>(_ => _.Selected).Returns(false);
option2.SetupGet<bool>(_ => _.Enabled).Returns(true);
option2.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();

new SelectElement(webElement.Object).SelectByIndex(2);
option1.Verify(_ => _.Selected, Times.Once);
option1.Verify(_ => _.Click(), Times.Once);
option1.Verify(_ => _.Selected, Times.Never);
option1.Verify(_ => _.Click(), Times.Never);
option1.Verify(_ => _.GetAttribute(It.IsAny<string>()), Times.Once);
option2.Verify(_ => _.Selected, Times.Once);
option2.Verify(_ => _.Click(), Times.Once);
Expand Down Expand Up @@ -352,7 +361,7 @@ public void CanDeselectMultipleOptionSelectedByIndex()

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("1");
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
option1.Setup(_ => _.Click());
option2.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
Expand All @@ -362,8 +371,8 @@ public void CanDeselectMultipleOptionSelectedByIndex()

new SelectElement(webElement.Object).DeselectByIndex(2);
option1.Verify(_ => _.GetAttribute(It.IsAny<string>()), Times.Once);
option1.Verify(_ => _.Selected, Times.Once);
option1.Verify(_ => _.Click(), Times.Once);
option1.Verify(_ => _.Selected, Times.Never);
option1.Verify(_ => _.Click(), Times.Never);
option2.Verify(_ => _.GetAttribute(It.IsAny<string>()), Times.Once);
option2.Verify(_ => _.Selected, Times.Once);
option2.Verify(_ => _.Click(), Times.Once);
Expand Down

0 comments on commit 3c74f07

Please sign in to comment.