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 SortedDictionary #623
Comments
@ploeh Do you have any thoughts on how to support custom comparer for the SortedDictionary Key. I just started on with this. It works fine for types that have a default comparer, but fails for complex types, objects etc. Would going down creating a custom request object with the comparer as a property be the right path. |
@ploeh Cool will use the Specification approach. But even with the sorted set specification approach, I don't see how this would work? var result = fixture.Create<SortedSet<object>>(); It fails with below error (as expected) Is that the expected behavior? |
What is it creating? |
@ploeh Sorry that got trimmed in markdown formatting Updated it SortedSet of object or any type that does not have a default comparer |
Is the situation different from when one requests |
When you ask AutoFixture for a dictionary, it provides a non-empty value:
When you request a sorted dictionary, on the other hand, the returned collection is empty. This test fails its assertion:
Since AutoFixture can already supply non-empty dictionaries, and one of the constructor overloads for
SortedDictionary<TKey, TValue>
takes a dictionary, it ought to be fairly easy to add a relay fromSortedDictionary<TKey, TValue>
toIDictionary<TKey, TValue>
.The implementation could for example be a new
ISpecimenBuilder
that handles requests for anySortedDictionary<TKey, TValue>
by resolvingIDictionary<TKey, TValue>
from thecontext
, and then invoking the appropriate constructor overload with the returned value.Another implementation option is to mimic the way concrete dictionaries are already filled. See the combination of
DictionaryFiller
andDictionarySpecification
in theFixture
class.The text was updated successfully, but these errors were encountered: