Created
October 11, 2013 06:51
-
-
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)
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
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