Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Behavioral.Automation/Behavioral.Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The whole automation code is divided into the following parts:
- UI structure descriptive code
- Supportive code</Description>
<Copyright>Quantori Inc.</Copyright>
<PackageVersion>1.8.5</PackageVersion>
<PackageVersion>1.8.6</PackageVersion>
<RepositoryUrl>https://github.com/quantori/Behavioral.Automation</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
15 changes: 8 additions & 7 deletions src/Behavioral.Automation/Bindings/DropdownBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}

/// <summary>
Expand All @@ -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));
}
}

Expand All @@ -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));
}

/// <summary>
Expand Down Expand Up @@ -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));
}

/// <summary>
Expand Down
15 changes: 15 additions & 0 deletions src/Behavioral.Automation/Services/PrintValuesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,20 @@ public static string GetPrintableValues([NotNull] this IEnumerable<ITableRowWrap

return "\r\n Rows collection was empty";
}

/// <summary>
/// Method that returns error message with elements aggregation
/// </summary>
/// <param name="caption">wrapper caption</param>
/// <param name="items">collection of dropdown elements in string form</param>
/// <returns>Error message with actual collection items</returns>
public static string CreateDropdownErrorMessage(this IEnumerable<string> 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}")}";
}
}
}