ameniameni / moq

Automatically exported from code.google.com/p/moq
Other
0 stars 0 forks source link

NullReferenceException thrown when using Mocks.CreateQuery with implicit boolean expression #207

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

var context = Mocks.CreateQuery<ControllerContext>().Where(c => 
c.HttpContext.User.IsInRole("admin")).First();

What is the expected output? What do you see instead?

Expect that no exception is thrown.

Actual Output:

System.NullReferenceException: Object reference not set to an instance of an 
object.
at lambda_method(ExecutionScope , ControllerContext )
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Enumerable.First<TSource>(IEnumerable`1 source)
at lambda_method(ExecutionScope )
at System.Linq.EnumerableExecutor`1.Execute()
at 
System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute<S>(Expression 
expression)
at System.Linq.Queryable.First<TSource>(IQueryable`1 source)
at lambda_method(ExecutionScope )

What version of the product are you using?

trunk, SVN revision 634

Please provide any additional information below.

The following explicit expression works as expected:

var context = Mocks.CreateQuery<ControllerContext>().Where(c => 
c.HttpContext.User.IsInRole("admin") == true).First();

Original issue reported on code.google.com by michael....@gmail.com on 4 Sep 2009 at 12:54

GoogleCodeExporter commented 8 years ago

Original comment by kzu.net on 25 Oct 2009 at 4:09

GoogleCodeExporter commented 8 years ago
Rev #690

Original comment by marian...@gmail.com on 26 Jun 2010 at 2:04