Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill SortedSet #624

Closed
ploeh opened this issue May 18, 2016 · 1 comment
Closed

Fill SortedSet #624

ploeh opened this issue May 18, 2016 · 1 comment

Comments

@ploeh
Copy link
Member

ploeh commented May 18, 2016

When you ask AutoFixture for a hash set, it provides a non-empty value:

var fixture = new Fixture();
var actual = fixture.Create<HashSet<string>>();
Assert.NotEmpty(actual); // Succeeds

When you request a sorted set, on the other hand, the returned set is empty. This test fails its assertion:

var fixture = new Fixture();
var actual = fixture.Create<SortedSet<string>>();
Assert.NotEmpty(actual); // Fails

Since AutoFixture can already supply non-empty collections, and one of the constructor overloads for SortedSet<T> takes a IEnumerable<T>, it ought to be fairly easy to add a relay from SortedSet<T> to IEnumerable<T>.

The implementation could for example be a new ISpecimenBuilder that handles requests for any SortedSet<T> by resolving IEnumerable<T> from the context, and then invoking the appropriate constructor overload with the returned value.

Another implementation option is to mimic the way hash sets are already filled. See the combination of EnumerableFavoringConstructorQuery and HashSetSpecification in the Fixture class.

@ploeh
Copy link
Member Author

ploeh commented May 18, 2016

See also #622 and #623.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant