Skip to content

Commit

Permalink
Mocks for multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Dec 7, 2024
1 parent 120cc8b commit bcde363
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions dotnet/test/support/UI/SelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void ThrowUnexpectedTagNameExceptionWhenNotSelectTag()
public void CanCreateNewInstanceOfSelectWithNormalSelectElement()
{
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);

Assert.That(new SelectElement(webElement.Object).IsMultiple, Is.False);
}
Expand All @@ -59,7 +59,7 @@ public void CanCreateNewInstanceOfSelectWithNormalSelectElement()
public void CanCreateNewInstanceOfSelectWithMultipleSelectElement()
{
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");

Assert.That(new SelectElement(webElement.Object).IsMultiple, Is.True);
}
Expand All @@ -69,7 +69,7 @@ public void CanGetListOfOptions()
{
IList<IWebElement> options = new List<IWebElement>();
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options));

Assert.That(new SelectElement(webElement.Object).Options, Is.EqualTo(options));
Expand All @@ -85,7 +85,7 @@ public void CanGetSingleSelectedOption()
options.Add(selected.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
notSelected.SetupGet<bool>(_ => _.Selected).Returns(false);
selected.SetupGet<bool>(_ => _.Selected).Returns(true);
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
Expand All @@ -107,7 +107,7 @@ public void CanGetAllSelectedOptions()
options.Add(notSelected.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
notSelected.SetupGet<bool>(_ => _.Selected).Returns(false);
selected.SetupGet<bool>(_ => _.Selected).Returns(true);
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
Expand All @@ -128,7 +128,7 @@ public void CanSetSingleOptionSelectedByText()
options.Add(option1.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
Expand All @@ -148,7 +148,7 @@ public void CanSetSingleOptionSelectedByValue()
options.Add(option1.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
Expand All @@ -168,7 +168,7 @@ public void CanSetSingleOptionSelectedByIndex()
options.Add(option1.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
webElement.Setup(_ => _.GetDomAttribute(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);
Expand All @@ -192,7 +192,7 @@ public void CanSetMultipleOptionSelectedByText()
options.Add(option2.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
Expand All @@ -219,7 +219,7 @@ public void CanSetMultipleOptionSelectedByValue()
options.Add(option2.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
option1.Setup(_ => _.Click());
Expand All @@ -246,7 +246,7 @@ public void CanSetMultipleOptionSelectedByIndex()
options.Add(option2.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("1");
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
Expand Down Expand Up @@ -275,7 +275,7 @@ public void CanDeselectSingleOptionSelectedByText()
options.Add(option1.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
option1.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
Expand All @@ -294,7 +294,7 @@ public void CanDeselectSingleOptionSelectedByValue()
options.Add(option1.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
option1.Setup(_ => _.Click());
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
Expand All @@ -313,7 +313,7 @@ public void CanDeselectSingleOptionSelectedByIndex()
options.Add(option1.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
option1.Setup(_ => _.Click());
Expand All @@ -336,7 +336,7 @@ public void CanDeselectMultipleOptionSelectedByText()
options.Add(option2.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
option1.Setup(_ => _.Click());
option2.SetupGet<bool>(_ => _.Selected).Returns(true);
Expand All @@ -356,7 +356,7 @@ public void CanDeselectMultipleOptionSelectedByValue()
options.Add(option2.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
option1.Setup(_ => _.Click());
option2.SetupGet<bool>(_ => _.Selected).Returns(true);
Expand All @@ -381,7 +381,7 @@ public void CanDeselectMultipleOptionSelectedByIndex()
options.Add(option2.Object);

webElement.SetupGet<string>(_ => _.TagName).Returns("select");
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
webElement.Setup(_ => _.GetDomAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("1");
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
option1.Setup(_ => _.Click());
Expand Down Expand Up @@ -409,7 +409,7 @@ public void SelectedOptionPropertyShouldThrowExceptionWhenNoOptionSelected()
options.Add(notSelected.Object);

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

Expand Down

0 comments on commit bcde363

Please sign in to comment.