AutoFixture/AutoFixture — pull request #318 by ecampidoglio (2014-10-15 21:29:09+00:00)
Title: Freeze on match data attribute

This `CustomizeAttribute` leverages the `FreezeOnMatchCustomization` introduced in #317 by opening up its behavior to xUnit parameterized tests.

### Usage

The `FreezeAttribute` applies to the same scenarios as the current `FrozenAttribute`. Here's an example:

```csharp
[Theory, AutoData]
public void FreezeParameterForMatchingProperties(
[Freeze(By = Matching.PropertyName, TargetName = "Property")]string p1,
PropertyHolder p2)
{
Assert.Same(p1, p2.Property);
}
```

Following the same convention as the `FreezeOnMatchCustomization`, if no matching criteria are specified the attribute will mimic the behavior of the current `FrozenAttribute` matching only by _exact type_. In other words the following test:

```csharp
[Theory, AutoData]
public void FreezeParameterByExactType(
[Freeze]string p1,
string p2)
{
Assert.Same(p1, p2);
}
```

is the same as:

```csharp
[Theory, AutoData]
public void FreezeParameterByExactType(
[Freeze(By = Matching.ExactType)]string p1,
string p2)
{
Assert.Same(p1, p2);
}
```

The existing `As` functionality of the `FrozenAttribute` is also superseded by using the `Matching.ImplementedInterfaces` criteria.

For example, given `IFoo` and `Bar` where `Bar` implements `IFoo`, the following test:

```csharp
[Theory, AutoData]
public void FreezeParameterByExactType(
[Frozen(As = typeof(IFoo))]Bar p1,
IFoo p2)
{
Assert.Same(p1, p2);
}
```

can now be expressed as:

```csharp
[Theory, AutoData]
public void FreezeParameterByExactType(
[Freeze(By = Matching.ImplementedInterfaces)]Bar p1,
IFoo p2)
{
Assert.Same(p1, p2);
}
```

which will also match _any other interface_ implemented by `Bar`.

### Follow-ups

The are a few things I deliberately left out until after I gather your feedback:

- Since the `FreezeAttribute` effectively supersedes the existing `FrozenAttribute`, I propose we obsolete it and keep the "_Freeze_" prefix for consistency with the `FreezeCustomization`.
- I'll add the XML documentation once the feature is finalized.

I look forward to your comments.