-
Notifications
You must be signed in to change notification settings - Fork 337
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 ReadonlyCollectionPropertiesBehavior does not select collection Add method correctly #1339
Comments
You already figured out the problem. The current source code expects the following: As you are using a Dictionary<TKey, TValue> that is not the case. As this class implements ICollection<KeyValuePair<TKey, TValue>> and explicitly implements the interface. Simplified AutoFixture uses the following code:
while it should use this
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the Bug
ReadonlyCollectionPropertiesBehavior
does not select collectionAdd
method correctly.The
ReadonlyCollectionPropertiesCommand
class tries to select any method calledAdd
:AutoFixture/Src/AutoFixture/Kernel/ReadonlyCollectionPropertiesCommand.cs
Lines 57 to 62 in 730b478
This is incorrect in two ways:
Add
method which then causes an exception fromSingleOrDefault
Add
. It should likely specifically selectICollection<>.Add
(though that's probably still not fully specific as the type may implement multipleICollection<>
)Scenario
In this scenario the readonly collection property is a
Dictionary<,>
which has multipleAdd
methods.Expected Behavior
Code above should not throw. Items should be added to the dictionary.
Tasks
Using AutoFixture 4.17
The text was updated successfully, but these errors were encountered: