5

We are currently running this expression

return x => x.ObjectType != null && x.ObjectType == "SERVICE"
                        && x.Service.Id == searchValue;

Which works fine until we come to do a unit test with just mock and it fails with the following exception:

The operands for operator 'Equal' do not match the parameters of method 'op_Equality'

The part of the expression that fails is the null check. If I replace the expression with just the null check and do the following it fails:

_unitOfWork.Repository<Widgits, int>().FindAll(x => x.ObjectType != null);

Does anyone know why this would only cause a problem when Unit Testing?

Lucas Trzesniewski
  • 50,214
  • 11
  • 107
  • 158
paj7777
  • 311
  • 1
  • 4
  • 13

0 Answers0