techtalk/SpecFlow — pull request #187 by rdumont (2012-05-29 06:47:33+00:00)
Title: Overridable value retrievers

I simply changed the way value retrievers are used in SpecFlow Assist. Absolutely nothing gets broken and we get the advantage of being able to use custom value retrievers in our projects.

What does that mean, exactly? Lets say that I want to use a specific format of relative dates when creating an instance (e.g. "1 hour ago"). Normally, I would have to create a special step only for that. Now I can do this:

```csharp
[BeforeTestRun]
public static void BeforeTestRun()
{
ValueRetrieverCollection.ValueRetrievers[typeof (DateTime)] = () => new MyCustomDateTimeValueRetriever();
}
```

Then, by correctly implementing the custom DateTime value retriever (why don't you check out [Dately](https://github.com/rdumont/Dately)?), I could just write the following step and have the desired result:

```
Given the following person
| Field | Value |
| BirthDate | 18 years ago |
```

```csharp
[Given(@"the following person")]
public void Given_the_following_person(Table table)
{
var person = table.CreateInstance();
// do something with the instance...
}
```
```csharp
public class Person
{
// ...
public DateTime BirthDate { get; set; }
}
```

I consider this an awesome feature and my example is just one use for it. I'm sure that other people are going to find many others. By the way, this works for comparing instances and sets too.

Gáspár, do you think this could by any chance slip into version 1.9.0 if it is approved?

Thank you!