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 have the following code:
[Test]
[VerifyMocks]
public void Valid_username_and_password_return_OK()
{
    var fake = new[] { new Data.User() };
    using (var r = new RecordExpectations())
    {
        var db = new InsightDataContext();
        var users = db.Users.Where(u => u.Username == "foo" && u.PasswordHash == null);
        r.Return(fake);
    }

    var session = new Session { Username = "foo" };
    session.Put();
}


The session object is basically checking that a user exists. However, when running the test I get a TypeMock exception.

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

I am using TypeMock v4.2.1.0.

This is my first time using TypeMock, so let me know if I've missed something obvious... thanks!
asked by andrewdavey (640 points)

10 Answers

0 votes
Hi,

sorry for the late answer,

try splitting the db.Users statement from the linq query itself. it might do the trick.
also please post the exact type of db.Users return value.
We are expereincing some issue with mocking of LINQ for some types and it might be related.
answered by lior (13.2k points)
0 votes
Splitting the db.Users out didn't help.
It gives me an exception:
"Cannot return a value for InsightDataContext.get_Users() because no value was set. use recorder.Return()."

Obviously it would need some data provided to return, but then that would not really be mocking the right stuff.

The type of db.Users is System.Data.Linq.Table<Equin.Insight.Data.User>
i.e. a table of LINQ data objects.
answered by andrewdavey (640 points)
0 votes
Hi,

Thanx for the response.
Looking at the return type it looks like you have stumbled upon a defect that we are currently fixing.

Its a tough one so it might take sometime. I'll notify you as soon as a fix is avaliable.
answered by lior (13.2k points)
0 votes
I have the same problem. Any updates on a fix?
answered by petteroe (3k points)
0 votes
Hi Morten,

We are in the final stages of fixing this issue. Once it's out, we'll send you a patch. Hope it will be soon.
answered by gilz (14.5k points)
0 votes
I now have Isolator version 4.2.3, and I still have the same problem. Any word on when the fix will be ready?

Thanks,

Morten
answered by petteroe (3k points)
0 votes
Hi,

Sorry for the delay in the fix.
This one was really harder then we originally thought.

In any case I'm estimated were a matter of days from completing the fix for this. So most likely it will be included in our next release.

In any case ill forward you the fix the moment it will be available.
answered by lior (13.2k points)
0 votes
Hi,

I am sorry about nagging too much about this, but do you have an estimated ETA for this fix?

Thanks,

Morten
answered by petteroe (3k points)
0 votes
Hi Morten,

We don't mind the nagging, we understand the urgency. And keeps us on our toes.
The fix will be published on our site in a couple of days.

Thanks for your patience.
answered by gilz (14.5k points)
0 votes
Hi everyone,

We've got some fixes for mocking LINQ queries in version 4.3. Please go download it at https://www.typemock.com/Downloads.php
answered by gilz (14.5k points)
...