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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: ExampleBinding

@Automated
Scenario: Open Google page
When user opens URL "https://www.google.com/"
Then page title should become "Google"

34 changes: 17 additions & 17 deletions src/App/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Behavioral.Automation/Bindings/AttributeBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public void CheckElementIsDisabled(
[NotNull] AssertionBehavior behavior,
bool enabled)
{
var status = enabled ? " not" : string.Empty;
Assert.ShouldBecome(() => element.Enabled, enabled, behavior,
$"{element.Caption} is{behavior.BehaviorAppendix()} enabled");
$"{element.Caption} is{status} enabled");
}

[StepArgumentTransformation("(enabled|disabled)")]
Expand Down
4 changes: 3 additions & 1 deletion src/Behavioral.Automation/Bindings/DropdownBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ private void CheckDropdownValueCollectionEnabled([NotNull] string behavior,
{
foreach (var row in table.Rows)
{
runnerAction($"the \"{row.Values.First()} \" value {behavior} {enabled} in {wrapper.Caption}:");
Assert.ShouldBecome(() => row.Values.Any(), true, new AssertionBehavior(AssertionType.Immediate, false),
"One of the rows in the provided table doesn't have values");
runnerAction($"the \"{row.Values.First()}\" value {behavior} {enabled} in {wrapper.Caption}");
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/Behavioral.Automation/Bindings/TableBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public void CheckTableHaveRows(ITableWrapper gridRows, string behavior, Table ta
Assert.ShouldBecome(() => gridRows.Rows.ToStringRows().DoesntContainValues(table.Rows.ToStringRows()),
true,
new AssertionBehavior(AssertionType.Immediate, true),
$"{gridRows.Caption} is {gridRows.Rows.GetPrintableValues()}");
$"{gridRows.Caption} is: {gridRows.Rows.GetPrintableValues()}");
}
else
{

Assert.ShouldBecome(() => gridRows.Rows.ToStringRows().HaveValues(table.Rows.ToStringRows(), false),
true,
new AssertionBehavior(AssertionType.Immediate, false),
$"{gridRows.Caption} is {gridRows.Rows.GetPrintableValues()}");
$"{gridRows.Caption} is: {gridRows.Rows.GetPrintableValues()}");
}
}

Expand All @@ -53,7 +53,7 @@ public void CheckTableHaveRowsInExactOrder(ITableWrapper gridRows, Table table)
Assert.ShouldBecome(() => gridRows.Rows.ToStringRows().HaveValues(table.Rows.ToStringRows(), true),
true,
new AssertionBehavior(AssertionType.Immediate, false),
$"{gridRows.Caption} is {gridRows.Rows.GetPrintableValues()}");
$"{gridRows.Caption} is: {gridRows.Rows.GetPrintableValues()}");
}

[Given("(.+?) (contains|does not contain) the following rows:")]
Expand All @@ -68,14 +68,14 @@ public void CheckTableContainsRows(ITableWrapper gridRows, string behavior, Tab
Assert.ShouldBecome(() => gridRows.Rows.ToStringRows().DoesntContainValues(table.Rows.ToStringRows()),
true,
new AssertionBehavior(AssertionType.Immediate, false),
$"{gridRows.Caption} is {gridRows.Rows.GetPrintableValues()}");
$"{gridRows.Caption} is: {gridRows.Rows.GetPrintableValues()}");
}
else
{
Assert.ShouldBecome(() => gridRows.Rows.ToStringRows().ContainsValues(table.Rows.ToStringRows()),
true,
new AssertionBehavior(AssertionType.Immediate, false),
$"{gridRows.Caption} is {gridRows.Rows.GetPrintableValues()}");
$"{gridRows.Caption} is: {gridRows.Rows.GetPrintableValues()}");
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/Behavioral.Automation/Services/PrintValuesHelper.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
using System.Collections.Generic;
using System.Linq;
using Behavioral.Automation.Elements;
using JetBrains.Annotations;

namespace Behavioral.Automation.Services
{
public static class PrintValuesHelper
{
public static string GetPrintableValues(this IEnumerable<ITableRowWrapper> rows)
public static string GetPrintableValues([NotNull] this IEnumerable<ITableRowWrapper> rows)
{
return rows.SelectMany(x => x.CellsText).Aggregate((x, y) => $"{x}, {y}");
if (rows.Any())
{
var values = rows.Aggregate("\r\n|", (current, row) => current + (row.CellsText.Aggregate((x, y) => $" {x} | {y}") + " |\r\n |"));
return values.Remove(values.Length - 3);
}

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