Skip to content

Commit 7228f55

Browse files
authored
Merge pull request #85 from quantori/BAP-69-dropdown-multiple-contain
BAP-69 Added dropdown binding with multiple contain check
2 parents b473999 + df88cf4 commit 7228f55

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Behavioral.Automation/Bindings/DropdownBinding.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void CheckDropdownHeaders([NotNull] IGroupedDropdownWrapper wrapper, [Not
4141
CheckDropdownElements(wrapper.GroupTexts, items, $"{wrapper.Caption} groups");
4242
}
4343

44-
[When("(.*?) (contain|not contain) \"(.*)\"")]
44+
[Given("(.*?) (contain|not contain) \"(.*)\"")]
4545
[Then("(.*?) should (contain|not contain) \"(.*)\"")]
4646
public void CheckDropdownContainsItems(
4747
[NotNull] IDropdownWrapper wrapper,
@@ -54,6 +54,23 @@ public void CheckDropdownContainsItems(
5454
$"{wrapper.Caption} items are {wrapper.Items.Aggregate((x, y) => $"{x}, {y}")}");
5555
}
5656

57+
[Given("the (.*?) (contains|not contains) the following values:")]
58+
[Then("the (.*?) should (contain|not contain) the following values:")]
59+
[Then("the \"(.*?)\" menu should (contain|not contain) the following values:")]
60+
public void CheckDropdownContainsMultipleItems([NotNull] IDropdownWrapper wrapper, [NotNull] string behavior, [NotNull] Table table)
61+
{
62+
Assert.ShouldBecome(()=> table.Rows.Any(),true,
63+
new AssertionBehavior(AssertionType.Immediate, false), "Please provide data in the table");
64+
65+
var dropdownItems = wrapper.Items;
66+
foreach (var row in table.Rows)
67+
{
68+
var value = row.Values.FirstOrDefault();
69+
Assert.ShouldBecome(()=>dropdownItems.Contains(value), !behavior.Contains("not"),
70+
$"{wrapper.Caption} items are {dropdownItems.Aggregate((x, y) => $"{x}, {y}")}");
71+
}
72+
}
73+
5774
[Then("all items in the (.+?) should (have|not have) \"(.+?)\"")]
5875
public void CheckAllItemsContainString(
5976
[NotNull] IDropdownWrapper wrapper,

0 commit comments

Comments
 (0)