tags:

views:

92

answers:

2

I'm not sure what i'm doing wrong, but this line of code is never returning (seems to result in a run-away process) when running it in a test:

var discountMemberCustomer = (from customer in Mocks.Query<Customer>()
    where customer.IsDiscountMember &&
        customer.OrderCount == 13 &&
        customer.LifetimeCustomerValue == 5555m
        select customer).First();

As far as I can tell, I'm following the examples: http://www.clariusconsulting.net/blogs/kzu/archive/2009/08/13/164978.aspx

+2  A: 

Try "setting" IsDiscountMember:

...
where customer.IsDiscountMember == true &&
...
dahlbyk
Wow, that was easy, you think I would have tried that... :P Note to self: Don't listen to ReSharper saying "Remove redundant comparison"
Chris Missal
Yeah, it's weird because they're using comparison equality instead of assignment equality. Incidentally, expression trees can't represent assignment until .NET 4.0, at which point expression tree of mocking can be done without abusing query syntax.
dahlbyk
A: 

Wow, that's a good catch! Can you report it as an issue in google code??

kzu
Failing test attached to the issue here as well as the mailing list:http://code.google.com/p/moq/issues/detail?id=206
Chris Missal
Fixed: http://code.google.com/p/moq/source/detail?r=641
Chris Missal