Skip to content

Commit 5752a58

Browse files
committed
added empty collection checks
1 parent 3b7b4b1 commit 5752a58

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using Behavioral.Automation.Elements;
4+
using JetBrains.Annotations;
45

56
namespace Behavioral.Automation.Services
67
{
78
public static class PrintValuesHelper
89
{
9-
public static string GetPrintableValues(this IEnumerable<ITableRowWrapper> rows)
10+
public static string GetPrintableValues([NotNull] this IEnumerable<ITableRowWrapper> rows)
1011
{
11-
var values = rows.Aggregate("\r\n|", (current, row) => current + (row.CellsText.Aggregate((x, y) => $" {x} | {y}") + " |\r\n |"));
12-
return values.Remove(values.Length - 3);
12+
if (rows.Any())
13+
{
14+
var values = rows.Aggregate("\r\n|", (current, row) => current + (row.CellsText.Aggregate((x, y) => $" {x} | {y}") + " |\r\n |"));
15+
return values.Remove(values.Length - 3);
16+
}
17+
18+
return "\r\n Rows collection was empty";
1319
}
1420
}
1521
}

0 commit comments

Comments
 (0)