|
1 | 1 | using System; |
| 2 | +using System.Collections.Generic; |
2 | 3 | using System.Linq; |
3 | | -using FluentAssertions; |
4 | 4 | using Behavioral.Automation.Elements; |
5 | 5 | using Behavioral.Automation.FluentAssertions; |
6 | 6 | using Behavioral.Automation.Model; |
@@ -32,13 +32,13 @@ public void CheckSelectedValue([NotNull] IDropdownWrapper wrapper, AssertionBeha |
32 | 32 | [Then("the (.*?) should have the following values:")] |
33 | 33 | public void CheckAllItems([NotNull] IDropdownWrapper wrapper, [NotNull] Table items) |
34 | 34 | { |
35 | | - wrapper.Items.Should().BeEquivalentTo(items.Rows.Select(x => x.Values.Single())); |
| 35 | + CheckDropdownElements(wrapper.Items, items, $"{wrapper.Caption} values"); |
36 | 36 | } |
37 | 37 |
|
38 | 38 | [Then("(.*?) should have the following groups:")] |
39 | 39 | public void CheckDropdownHeaders([NotNull] IGroupedDropdownWrapper wrapper, [NotNull] Table items) |
40 | 40 | { |
41 | | - wrapper.GroupTexts.Should().BeEquivalentTo(items.Rows.Select(x => x.Values.Single())); |
| 41 | + CheckDropdownElements(wrapper.GroupTexts, items, $"{wrapper.Caption} groups"); |
42 | 42 | } |
43 | 43 |
|
44 | 44 | [When("(.*?) (contain|not contain) \"(.*)\"")] |
@@ -84,7 +84,7 @@ public void ClickOnMultipleEntries([NotNull] IMultiSelectDropdownWrapper wrapper |
84 | 84 | [Then("the following values should be selected in (.*?):")] |
85 | 85 | public void CheckMultipleSelectedValues([NotNull] IMultiSelectDropdownWrapper wrapper, [NotNull] Table values) |
86 | 86 | { |
87 | | - wrapper.SelectedValuesTexts.Should().BeEquivalentTo(values.Rows.Select(x => x.Values.Single())); |
| 87 | + CheckDropdownElements(wrapper.SelectedValuesTexts, values, $"{wrapper.Caption} selected values"); |
88 | 88 | } |
89 | 89 |
|
90 | 90 | [Given("the \"(.+?)\" value (is|become) (enabled|disabled) in (.+?)")] |
@@ -136,6 +136,17 @@ public void CheckDropdownIsEmpty([NotNull] IDropdownWrapper wrapper, [NotNull] A |
136 | 136 | Assert.ShouldBecome(() => wrapper.Empty, true, behavior, |
137 | 137 | $"{wrapper.Caption} selected value is{behavior.BehaviorAppendix()} empty"); |
138 | 138 | } |
| 139 | + |
| 140 | + private void CheckDropdownElements([NotNull] IEnumerable<string> actualValues, [NotNull] Table expectedValues, [NotNull] string valueType) |
| 141 | + { |
| 142 | + for (var i = 0; i < expectedValues.Rows.Count; i++) |
| 143 | + { |
| 144 | + var expectedValue = expectedValues.Rows.ElementAt(i).Values.FirstOrDefault(); |
| 145 | + var actualValue = actualValues.Any()? actualValues.ElementAt(i) : null; |
| 146 | + Assert.ShouldBecome(() => expectedValue, actualValue, |
| 147 | + $"Expected one of the {valueType} to be {expectedValue} but was {actualValue}"); |
| 148 | + } |
| 149 | + } |
139 | 150 | } |
140 | 151 | } |
141 | 152 |
|
0 commit comments