19 lines
478 B
C#
19 lines
478 B
C#
using OwnerNumberMigration.ValueParsing;
|
|
|
|
namespace OwnerNumberMigrationTest.TestDoubles;
|
|
|
|
public class FakeParsingStrategy<T> : IValueParsingStrategy<T>
|
|
{
|
|
public IDictionary<string, T> Values { get; } = new Dictionary<string, T>();
|
|
|
|
private readonly Func<T> _newT;
|
|
|
|
public FakeParsingStrategy(Func<T> newT)
|
|
{
|
|
this._newT = newT;
|
|
}
|
|
|
|
public T Parse(string value) => Values.TryGetValue(value, out var parsed)
|
|
? parsed
|
|
: _newT();
|
|
} |