7 Answers, 1 is accepted
Thanks for the post, i tested your code , yes there were some issue with Justmock setting up null value for List/Dictionary. You can tell me your email address i can send you a build personally if it is too urgent for you.
However, i would like to inform you that returning null for list is a design violation according to frameowrk design guidelines. You might like to check this:
Also, you can't return null directly like one you mentioned:
Rather you will have to do:
The previous one acutally wont build as there are other overloads and you need to tell the compiler what overload you acutally want to pick up and set null. Our of curiousity, i found an interesting issue simiilar posted in a forum at google groups for Moq.
Hope that helps,
The build / release is scheduled for early july. Of course in between, if you find more issues just let us know or shoot me an email at firstname.lastname@example.org
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
I've tried various other ways to mock the return but nothing seems to work other than changing the return type of the method. The method returns an object array. If I change the return type to something like an IList(of Object), Mock.Arrange seems to let me return null, but this isn't really a change I want to make. Any ideas?
Thanks again for sending the issue.
Yes we realized that it should not return default value when set explicitly. However it is fixed now and should you require an internal build please let me know. (In that regard, please open up s support ticket since we can't send internal builds on public forum).
Alternatively, we are planning for a patch on this coming Monday which also contains the fix.
Finally about the empty array, we follow framework design guidelines for returning default value for collection or array:
From the Framework Design Guidelines 2nd Edition  (pg. 256):
DO NOT return null values from collection properties or from methods returning collections. Return an empty collection or an empty array instead.
the Telerik team
I had this situation. I needed to test the managing that I was doing to null responses and I had something like this:
But with, still is returning an instance of ObjectDto.
I solvedtryed to use
but still getting me the empty instance instead the null so I changed for
The arrangements you are using should behave in the same way, the only difference is the scope that they are applicable to - the first two of them are applicable if there is an exact match of the given parameters in the arrangement expression, the last one - for any possible values of the parameters. I have made a sample project and played a little bit with this use case, but I am unable to observe such a problem, probably I have missed something. Please use the attached sample and modify it to match the issue and send it back to us for further investigation.
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.