Gal Ziv
Gal Ziv

Reputation: 7372

MOQ - verify method with parameter executed regardless of the parameter used

I have a method which inside calls another method.

This method has only one signature, for example:

 Koko(ComplexType isKoko)

I want to verify that this method executed without checking the instance of the parameter and doing something like this:

 It check_description = () => mockKoko.Verify(x => x.Koko(anything), Times.Once());

I searched the forum and Google and couldn't find an answer.

I'll appreciate any help.

Upvotes: 8

Views: 6943

Answers (2)

Code First
Code First

Reputation: 179

mock.Verify(m => m.MethodToCheckIfCalled(It.Is<IUserDTO>(x =>  x.LastName == "3" & x.FirstName == "2")));

Upvotes: 5

levelnis
levelnis

Reputation: 7705

You can use It.IsAny<ComplexType>():

check_description = () => mockKoko.Verify(x => x.Koko(It.IsAny<ComplexType>()), Times.Once());

Upvotes: 7

Related Questions