diff --git a/CHANGELOG.md b/CHANGELOG.md
index a8f3d347..5f8bfbac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+[1.8.6] - 2022-01-25
+### Fixed
+- Error when calling Aggregate() to generate message for DropdownWrapper
+
[1.8.5] - 2022-01-27
### Changed
- Bindings code refactoring
diff --git a/src/Behavioral.Automation/Behavioral.Automation.csproj b/src/Behavioral.Automation/Behavioral.Automation.csproj
index 9c0a50c8..fec60278 100644
--- a/src/Behavioral.Automation/Behavioral.Automation.csproj
+++ b/src/Behavioral.Automation/Behavioral.Automation.csproj
@@ -16,7 +16,7 @@ The whole automation code is divided into the following parts:
- UI structure descriptive code
- Supportive code
Quantori Inc.
- 1.8.5
+ 1.8.6
https://github.com/quantori/Behavioral.Automation
true
true
diff --git a/src/Behavioral.Automation/Bindings/DropdownBinding.cs b/src/Behavioral.Automation/Bindings/DropdownBinding.cs
index fe23f7dc..5d919cc5 100644
--- a/src/Behavioral.Automation/Bindings/DropdownBinding.cs
+++ b/src/Behavioral.Automation/Bindings/DropdownBinding.cs
@@ -4,6 +4,7 @@
using Behavioral.Automation.Elements;
using Behavioral.Automation.FluentAssertions;
using Behavioral.Automation.Model;
+using Behavioral.Automation.Services;
using JetBrains.Annotations;
using TechTalk.SpecFlow;
@@ -92,7 +93,7 @@ public void CheckDropdownContainsItems(
Assert.ShouldBecome(
() => wrapper.Items.Contains(value),
!behavior.Contains("not"),
- $"{wrapper.Caption} items are {wrapper.Items.Aggregate((x, y) => $"{x}, {y}")}");
+ wrapper.Items.CreateDropdownErrorMessage(wrapper.Caption));
}
///
@@ -111,15 +112,15 @@ public void CheckDropdownContainsItems(
[Then("the \"(.*?)\" menu should (contain|not contain) the following values:")]
public void CheckDropdownContainsMultipleItems([NotNull] IDropdownWrapper wrapper, [NotNull] string behavior, [NotNull] Table table)
{
- Assert.ShouldBecome(() => table.Rows.Any(), true,
+ Assert.ShouldBecome(()=> table.Rows.Any(),true,
new AssertionBehavior(AssertionType.Immediate, false), "Please provide data in the table");
- var dropdownItems = wrapper.Items;
+ var dropdownItems = wrapper.Items.ToArray();
foreach (var row in table.Rows)
{
var value = row.Values.FirstOrDefault();
- Assert.ShouldBecome(() => dropdownItems.Contains(value), !behavior.Contains("not"),
- $"{wrapper.Caption} items are {dropdownItems.Aggregate((x, y) => $"{x}, {y}")}");
+ Assert.ShouldBecome(()=>dropdownItems.Contains(value), !behavior.Contains("not"),
+ dropdownItems.CreateDropdownErrorMessage(wrapper.Caption));
}
}
@@ -140,7 +141,7 @@ public void CheckAllItemsContainString(
Assert.ShouldBecome(() => wrapper.Stale, false, $"{wrapper.Caption} is stale");
var items = wrapper.Items;
Assert.ShouldBecome(() => wrapper.Items.All(x => x.ToLower().Contains(value.ToLower().Trim())),
- !behavior.Contains("not"), $"{wrapper.Caption} items are {items.Aggregate((x, y) => $"{x}, {y}")}");
+ !behavior.Contains("not"), items.CreateDropdownErrorMessage(wrapper.Caption));
}
///
@@ -258,7 +259,7 @@ private void CheckDropdownValueCollectionEnabled([NotNull] string behavior,
[Then("no values should be selected in (.*?):")]
public void CheckMultiSelectDropdownHasNoValuesSelected([NotNull] IMultiSelectDropdownWrapper wrapper)
{
- Assert.ShouldBecome(() => !wrapper.SelectedValuesTexts.Any(), true, $"{wrapper.Caption} has the following values : {wrapper.SelectedValuesTexts.Aggregate((x, y) => $"{x}, {y}")}");
+ Assert.ShouldBecome(() => !wrapper.SelectedValuesTexts.Any(), true, wrapper.SelectedValuesTexts.CreateDropdownErrorMessage(wrapper.Caption));
}
///
diff --git a/src/Behavioral.Automation/Services/PrintValuesHelper.cs b/src/Behavioral.Automation/Services/PrintValuesHelper.cs
index cb76133e..ecfd6309 100644
--- a/src/Behavioral.Automation/Services/PrintValuesHelper.cs
+++ b/src/Behavioral.Automation/Services/PrintValuesHelper.cs
@@ -17,5 +17,20 @@ public static string GetPrintableValues([NotNull] this IEnumerable
+ /// Method that returns error message with elements aggregation
+ ///
+ /// wrapper caption
+ /// collection of dropdown elements in string form
+ /// Error message with actual collection items
+ public static string CreateDropdownErrorMessage(this IEnumerable items, string caption)
+ {
+ caption ??= "Collection";
+ if (items == null || !items.Any())
+ return $"'{caption}' is empty";
+
+ return $"Actual '{caption}' items are: {items.Aggregate((x, y) => $"{x}, {y}")}";
+ }
}
}