chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I am receiving the following error message when attempting to mock a DataContext object.

*** Cannot return a value for DB.get_Tabs() because no value was set. use recorder.Return().

I saw a previous forum post (https://www.typemock.com/community/viewtopic.php?t=727) which mentioned an issue such as this, but it was reported to have been fixed in 4.3. I am currently using 5.3.1.

Here is the offending code.

            var tabs = new Tab[1];
            var roles = new string[] { "PageEditor" };

            using (var r = new RecordExpectations())
            {
                var db = new DB();
                r.ExpectAndReturn(Roles.GetRolesForUser(), roles);
                r.ExpectAndReturn(db.Tabs.Where(x => roles.Contains(x.Role)).ToArray(),
                    tabs).RepeatAlways().WhenArgumentsMatch();
            }


The LINQ expression is causing the issue, because if I dummy down the query, it works fine....

            var tabs = new Tab[1];
            var roles = new string[] { "PageEditor" };

            using (var r = new RecordExpectations())
            {
                var db = new DB();
                r.ExpectAndReturn(Roles.GetRolesForUser(), roles);
                r.ExpectAndReturn(db.Tabs.Where(x => x.Role == "").ToArray(),
                    tabs).RepeatAlways().WhenArgumentsMatch();
            }


Is there a different way I should be handling this from a mocking perspective, or is this an issue within Isolator?

Thanks,

Jamison
asked by websiteLogic (600 points)

1 Answer

0 votes
Hi Jamisson,

I tried reproducing this issue on 5.3.1 with no luck. Could you please share a simple VS solution in which it happens? I would like to reproduce it here with the actual types being faked in your test.

Best Regards,
Elisha
Typemock Support Team
answered by Elisha (12k points)
...