0

Trying to verify that my service has been invoked. I don't care about the arguments, just that it was called once. I tried this

        A.CallTo(() => topicWriterFake.Write(A<string>.Ignored, A<string>.Ignored, A<IEnumerable<string>>.Ignored))
            .Returns(Task.CompletedTask);

//code that causes message to be written to bus

// now i try to verify that it has been called, but it fails with a message " Expected to find it once exactly but didn't find it among the calls:"

        A.CallTo(() => topicWriterFake.Write(A<string>.Ignored, A<string>.Ignored, A<IEnumerable<string>>.Ignored))
            .MustHaveHappenedOnceExactly();
epitka
  • 17,275
  • 20
  • 88
  • 141
  • Nothing is jumping out at me. What version are you using? Can you provide the whole error message, including the list of calls that the Fake did receive? Are you sure you didn't accidentally call a different overload of the `Write` method? Are you accidentally making a call on a different Fake (or non-Fake)? Please update your question with the full test code and as much of the relevant production code as you can. – Blair Conrad Dec 18 '18 at 13:57
  • @BlairConrad: Ahh there is overload for the thrid parameter that it is either IEnumerable or just string :). Thanks – epitka Dec 18 '18 at 14:12
  • 1
    BTW, you don't need to configure the method to return a completed task; that's the default behavior for fake methods that return a task. – Thomas Levesque Dec 18 '18 at 14:28

0 Answers0