This is a migrated thread and some comments may be shown as answers.

Entity Framework

1 Answer 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 16 Apr 2010, 12:56 PM
Anyone got any ideas on how I'd mock a call to a method that contains something similar to below. I realise I could mock the method call itself but I'm really after the method being entered and the linq statment returning values that don't actually exist in the db

using (OptimumWebRollEntities context = new OptimumWebRollEntities()) 
            { 
 
                returnList = (from u in context.OptimumUser 
                              where u.IsOptimumStaff == false 
                              && u.IsActive 
                              && u.Region.RegionId == regionId 
                              orderby u.Surname, u.FirstName 
                              select new data.ReportingEntities.Candidate() 
                              { 
                                  OptimumUserId = u.OptimumUserId, 
                                  FirstName = u.FirstName, 
                                  Surname = u.Surname 
                              }).ToList(); 
 
            } 
 

1 Answer, 1 is accepted

Sort by
0
Chris
Telerik team
answered on 20 Apr 2010, 10:31 AM
Hello Chris,
Indeed, it's better you mock the method call itself, otherwise you'll need to mock too many things which you're using in the method body and additionally you'll need to pass them as parameters.

Also, we are planning to support this type of direct mocking of LINQ queries as well in coming quarters.

Kind regards,
Chris
the Telerik team

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.
Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Telerik team
Share this question
or