Skip to content

Commit abebf0e

Browse files
committed
added .Unless extension method
some refactoring to make the code a bit more readable
1 parent cee1953 commit abebf0e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

TestStack.ConventionTests/Internal/ConventionResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public void IsSymmetric<TResult>(
5454
Func<TResult, bool> isPartOfSecondSet,
5555
IEnumerable<TResult> allData)
5656
{
57-
var firstSetFailingData = allData.Where(isPartOfFirstSet).Where(d => !isPartOfSecondSet(d));
58-
var secondSetFailingData = allData.Where(d => !isPartOfFirstSet(d)).Where(isPartOfSecondSet);
57+
var firstSetFailingData = allData.Where(isPartOfFirstSet).Unless(isPartOfSecondSet);
58+
var secondSetFailingData = allData.Where(isPartOfSecondSet).Unless(isPartOfFirstSet);
5959

6060
IsSymmetric(
6161
firstSetFailureTitle, firstSetFailingData,

TestStack.ConventionTests/Internal/LinqExtensions.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// ReSharper disable once CheckNamespace
2-
3-
namespace TestStack.ConventionTests.Internal
1+
namespace TestStack.ConventionTests.Internal
42
{
53
using System;
64
using System.Collections.Generic;
@@ -17,5 +15,11 @@ public static bool None<T>(this IEnumerable<T> enumerable, Func<T, bool> predica
1715
{
1816
return !enumerable.Any(predicate);
1917
}
18+
19+
20+
public static IEnumerable<T> Unless<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
21+
{
22+
return enumerable.Where(i => predicate(i) == false);
23+
}
2024
}
2125
}

0 commit comments

Comments
 (0)