Skip to content

Instantly share code, notes, and snippets.

@Seikilos
Created October 11, 2013 06:51
Show Gist options
  • Save Seikilos/6930575 to your computer and use it in GitHub Desktop.
Save Seikilos/6930575 to your computer and use it in GitHub Desktop.
AutoFixture hint by moodmosaic on how to add ObservableCollection support (From AutoFixture issue https://github.com/AutoFixture/AutoFixture/issues/191#issuecomment-26084930)
fixture.Customizations.Add(
new FilteringSpecimenBuilder(
new MethodInvoker(
new EnumerableFavoringConstructorQuery()),
new ObservableCollectionSpecification()));
internal class ObservableCollectionSpecification : IRequestSpecification
{
public bool IsSatisfiedBy(object request)
{
var type = request as Type;
if (type == null)
return false;
return type.IsGenericType
&& typeof(ObservableCollection<>) == type.GetGenericTypeDefinition();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment