-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preliminary work on adding a table helpers class that can be resolved…
… from the DI. This enables per-scenario differing value retrievers.
- Loading branch information
Showing
53 changed files
with
1,310 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...s/Reqnroll.SpecFlowCompatibility.ReqnrollPlugin/Wrappers/SetComparisonExtensionMethods.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Reqnroll.Assist | ||
{ | ||
public static class FindInSetExtensionMethods | ||
{ | ||
[Obsolete("Use TableHelpers instead")] | ||
public static T FindInSet<T>(this Table table, IEnumerable<T> set) | ||
{ | ||
var instanceTable = TEHelpers.GetTheProperInstanceTable(table, typeof (T)); | ||
var instanceTable = TEHelpers.GetTheProperInstanceTable(table, typeof(T)); | ||
|
||
var matches = set.Where(instance => InstanceMatchesTable(instance, instanceTable)).ToArray(); | ||
var matches = set.Where(instance => InstanceMatchesTable(Service.Instance, instance, instanceTable)).ToArray(); | ||
|
||
if (matches.Length > 1) | ||
throw new ComparisonException("Multiple instances match the table"); | ||
if (matches.Length > 1) throw new ComparisonException("Multiple instances match the table"); | ||
|
||
return matches.FirstOrDefault(); | ||
} | ||
|
||
[Obsolete("Use TableHelpers instead")] | ||
public static IEnumerable<T> FindAllInSet<T>(this Table table, IEnumerable<T> set) | ||
{ | ||
var instanceTable = TEHelpers.GetTheProperInstanceTable(table, typeof (T)); | ||
var instanceTable = TEHelpers.GetTheProperInstanceTable(table, typeof(T)); | ||
|
||
return set.Where(instance => InstanceMatchesTable(instance, instanceTable)).ToArray(); | ||
return set.Where(instance => InstanceMatchesTable(Service.Instance, instance, instanceTable)).ToArray(); | ||
} | ||
|
||
private static bool InstanceMatchesTable<T>(T instance, Table table) | ||
private static bool InstanceMatchesTable<T>(Service service, T instance, Table table) | ||
{ | ||
return table.Rows.All(row => !InstanceComparisonExtensionMethods.ThereIsADifference(instance, row)); | ||
return table.Rows.All(row => !InstanceComparisonExtensionMethods.ThereIsADifference(service, instance, row)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Reqnroll.Assist | ||
{ | ||
public static class ProjectionExtensionMethods | ||
{ | ||
[Obsolete("Use TableHelpers instead")] | ||
public static IEnumerable<Projection<T>> ToProjection<T>(this IEnumerable<T> collection, Table table = null) | ||
{ | ||
return new EnumerableProjection<T>(table, collection); | ||
var tableHelpers = new TableHelpers(Service.Instance); | ||
return new EnumerableProjection<T>(tableHelpers, table, collection); | ||
} | ||
|
||
[Obsolete("Use TableHelpers instead")] | ||
public static IEnumerable<Projection<T>> ToProjection<T>(this Table table) | ||
{ | ||
return new EnumerableProjection<T>(table); | ||
var tableHelpers = new TableHelpers(Service.Instance); | ||
return new EnumerableProjection<T>(tableHelpers, table); | ||
} | ||
|
||
[Obsolete("Use TableHelpers instead")] | ||
public static IEnumerable<Projection<T>> ToProjectionOfSet<T>(this Table table, IEnumerable<T> collection) | ||
{ | ||
return new EnumerableProjection<T>(table); | ||
var tableHelpers = new TableHelpers(Service.Instance); | ||
return new EnumerableProjection<T>(tableHelpers, table); | ||
} | ||
|
||
[Obsolete("Use TableHelpers instead")] | ||
public static IEnumerable<Projection<T>> ToProjectionOfInstance<T>(this Table table, T instance) | ||
{ | ||
return new EnumerableProjection<T>(table); | ||
var tableHelpers = new TableHelpers(Service.Instance); | ||
return new EnumerableProjection<T>(tableHelpers, table); | ||
} | ||
} | ||
} |
Oops, something went wrong.