0

I keep getting the "Unsupported expression" exception. It seems that the lambda expression (a=>a.PP_EventID==1) is the problem. How do solved this one?

pricepackPersistenceMock.Setup(pricepack => pricepack.Delete(a=>a.PP_EventID==1)).Verifiable();
user335160
  • 1,364
  • 6
  • 32
  • 67

1 Answers1

1

You should use the predicate inside It.Is<T>() method.

pricepackPersistenceMock.Setup(pricepack => ricepack.Delete(It.Is<TypeOfa>(a=>a.PP_EventID==1)))
                        .Verifiable();

Update:

eventPersistenceMock.Setup(u => u.Single(It.IsAny<Func<tbl_SBAem_Event, bool>>()))
                    .Returns(eventlists.Where(a => a.EventMngID == currentevent.EventMngID).Single());
// you can directly return the value
//verifiable is not needed because you set the return value
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156