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

indexed properties don't "just work" like scalar properties #277

Closed
blairconrad opened this issue Mar 20, 2014 · 9 comments · Fixed by #311
Closed

indexed properties don't "just work" like scalar properties #277

blairconrad opened this issue Mar 20, 2014 · 9 comments · Fixed by #311

Comments

@blairconrad
Copy link
Member

Inspired by a StackOverflow question

If a value is set on the "Item property", the next "get" will return the key that was used to set the value, not the value. Check out this setup:

[Test]
public void BadItemProperty()
{
    var session = A.Fake<Session>();

    A.CallTo(() => session["key1"]).Returns("value1");

    Assert.That(session["key1"], Is.EqualTo("value1"));

    session["key2"] = "value2";
    Assert.That(session["key2"], Is.EqualTo("value2")); // fails - it's key2

    Assert.That(session["key1"], Is.EqualTo("value1"), "second go"); // would also fail - it's also key2
}
@blairconrad
Copy link
Member Author

Marking as P3 and an enhancement (could be a bug, but I don't think we make any promises, so I'm going with "enhancement").

@blairconrad
Copy link
Member Author

I think reasonable default behaviour would be to act like we've got a dictionary back there and return the values that are saved.

@blairconrad blairconrad changed the title unconfigured Item indexed properties don't "just work" like scalar properties indexed properties don't "just work" like scalar properties Apr 17, 2014
@blairconrad
Copy link
Member Author

Given the information provided by @flandersen in #293, I updated the title of this issue to include all indexed properties, since I suspect the cause of the two issues is the same. (Of course, indexed non-this properties are not available in C#, just VB.Net. But that's not reason for them to not work.)

@blairconrad
Copy link
Member Author

Marking as 2 - Working and P2, since we have a related #293, reported by a user, and assigning to me.

@blairconrad
Copy link
Member Author

@afromogli, are you the same AfroMogli that asked the question on StackOverflow?

@afromogli
Copy link

Yes, that is correct :)

@blairconrad
Copy link
Member Author

Thanks. Just wanted to make sure I was giving proper credit in the 1.21.0 release notes!

@afromogli
Copy link

Allright, Thank you!

26 maj 2014 kl. 19:27 skrev Blair Conrad notifications@github.com:

Thanks. Just wanted to make sure I was giving proper credit in the 1.21.0 release notes!


Reply to this email directly or view it on GitHub.

@blairconrad
Copy link
Member Author

@afromogli, thanks very much for raising this issue. Look for your name in the release notes. 🏆

This issue has been fixed in release 1.21.0.

https://www.nuget.org/packages/FakeItEasy/1.21.0
https://github.com/FakeItEasy/FakeItEasy/releases/tag/1.21.0

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

Successfully merging a pull request may close this issue.

3 participants