Skip to content

Commit a5bd3ba

Browse files
Merge pull request #103 from quantori/fix/exception-on-aggregate-call-fix
Fix/exception on aggregate call fix
2 parents 12b904a + 8a6a6ee commit a5bd3ba

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
[1.8.6] - 2022-01-25
8+
### Fixed
9+
- Error when calling Aggregate() to generate message for DropdownWrapper
10+
711
[1.8.5] - 2022-01-27
812
### Changed
913
- Bindings code refactoring

src/Behavioral.Automation/Behavioral.Automation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The whole automation code is divided into the following parts:
1616
- UI structure descriptive code
1717
- Supportive code</Description>
1818
<Copyright>Quantori Inc.</Copyright>
19-
<PackageVersion>1.8.5</PackageVersion>
19+
<PackageVersion>1.8.6</PackageVersion>
2020
<RepositoryUrl>https://github.com/quantori/Behavioral.Automation</RepositoryUrl>
2121
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2222
<IncludeSymbols>true</IncludeSymbols>

src/Behavioral.Automation/Bindings/DropdownBinding.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Behavioral.Automation.Elements;
55
using Behavioral.Automation.FluentAssertions;
66
using Behavioral.Automation.Model;
7+
using Behavioral.Automation.Services;
78
using JetBrains.Annotations;
89
using TechTalk.SpecFlow;
910

@@ -92,7 +93,7 @@ public void CheckDropdownContainsItems(
9293
Assert.ShouldBecome(
9394
() => wrapper.Items.Contains(value),
9495
!behavior.Contains("not"),
95-
$"{wrapper.Caption} items are {wrapper.Items.Aggregate((x, y) => $"{x}, {y}")}");
96+
wrapper.Items.CreateDropdownErrorMessage(wrapper.Caption));
9697
}
9798

9899
/// <summary>
@@ -111,15 +112,15 @@ public void CheckDropdownContainsItems(
111112
[Then("the \"(.*?)\" menu should (contain|not contain) the following values:")]
112113
public void CheckDropdownContainsMultipleItems([NotNull] IDropdownWrapper wrapper, [NotNull] string behavior, [NotNull] Table table)
113114
{
114-
Assert.ShouldBecome(() => table.Rows.Any(), true,
115+
Assert.ShouldBecome(()=> table.Rows.Any(),true,
115116
new AssertionBehavior(AssertionType.Immediate, false), "Please provide data in the table");
116117

117-
var dropdownItems = wrapper.Items;
118+
var dropdownItems = wrapper.Items.ToArray();
118119
foreach (var row in table.Rows)
119120
{
120121
var value = row.Values.FirstOrDefault();
121-
Assert.ShouldBecome(() => dropdownItems.Contains(value), !behavior.Contains("not"),
122-
$"{wrapper.Caption} items are {dropdownItems.Aggregate((x, y) => $"{x}, {y}")}");
122+
Assert.ShouldBecome(()=>dropdownItems.Contains(value), !behavior.Contains("not"),
123+
dropdownItems.CreateDropdownErrorMessage(wrapper.Caption));
123124
}
124125
}
125126

@@ -140,7 +141,7 @@ public void CheckAllItemsContainString(
140141
Assert.ShouldBecome(() => wrapper.Stale, false, $"{wrapper.Caption} is stale");
141142
var items = wrapper.Items;
142143
Assert.ShouldBecome(() => wrapper.Items.All(x => x.ToLower().Contains(value.ToLower().Trim())),
143-
!behavior.Contains("not"), $"{wrapper.Caption} items are {items.Aggregate((x, y) => $"{x}, {y}")}");
144+
!behavior.Contains("not"), items.CreateDropdownErrorMessage(wrapper.Caption));
144145
}
145146

146147
/// <summary>
@@ -258,7 +259,7 @@ private void CheckDropdownValueCollectionEnabled([NotNull] string behavior,
258259
[Then("no values should be selected in (.*?):")]
259260
public void CheckMultiSelectDropdownHasNoValuesSelected([NotNull] IMultiSelectDropdownWrapper wrapper)
260261
{
261-
Assert.ShouldBecome(() => !wrapper.SelectedValuesTexts.Any(), true, $"{wrapper.Caption} has the following values : {wrapper.SelectedValuesTexts.Aggregate((x, y) => $"{x}, {y}")}");
262+
Assert.ShouldBecome(() => !wrapper.SelectedValuesTexts.Any(), true, wrapper.SelectedValuesTexts.CreateDropdownErrorMessage(wrapper.Caption));
262263
}
263264

264265
/// <summary>

src/Behavioral.Automation/Services/PrintValuesHelper.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,20 @@ public static string GetPrintableValues([NotNull] this IEnumerable<ITableRowWrap
1717

1818
return "\r\n Rows collection was empty";
1919
}
20+
21+
/// <summary>
22+
/// Method that returns error message with elements aggregation
23+
/// </summary>
24+
/// <param name="caption">wrapper caption</param>
25+
/// <param name="items">collection of dropdown elements in string form</param>
26+
/// <returns>Error message with actual collection items</returns>
27+
public static string CreateDropdownErrorMessage(this IEnumerable<string> items, string caption)
28+
{
29+
caption ??= "Collection";
30+
if (items == null || !items.Any())
31+
return $"'{caption}' is empty";
32+
33+
return $"Actual '{caption}' items are: {items.Aggregate((x, y) => $"{x}, {y}")}";
34+
}
2035
}
2136
}

0 commit comments

Comments
 (0)