0

I have this method in my C# code:

public virtual bool VarselDAL_HentAvtaleForVarsling(
            DateTime varselDato, 
            out AvtaleForVarsling avtaleForVarsling)

which I'm trying to moq the service call. But I'm facing trouble with the out-parameter of my method.

Can anyone please hit me with right generics? I tried this one but of no use:

resMock.Setup(
           res => res.VarselDAL_HentAvtaleForVarsling(It.IsAny<DateTime>(), out _avtale))
                 .Returns(true).AtMostOnce().Verifiable()  
Nkosi
  • 235,767
  • 35
  • 427
  • 472
  • 1
    [This blog might help](https://weblogs.asp.net/avnerk/moq-callbacks-and-out-parameters-a-particularly-tricky-edge-case) – Matthew Watson Nov 21 '16 at 13:47
  • OutCallback, and Callback() are used for method having void type. I have Boolean return type. I tried this, but the service call couldn't get mocked. var avtaleForVarslin = new AvtaleForVarsling() { //entered some values }; resMock.Setup(res => res.VarselDAL_HentAvtaleForVarsling(It.IsAny(), out avtaleForVarslin)) .Returns(true).AtMostOnce().Verifiable(); – Niraja_ Nov 23 '16 at 06:08

0 Answers0