Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 285
Gal Ziv Avatar asked Apr 15 '13 08:04

Gal Ziv


2 Answers

mock.Verify(m => m.MethodToCheckIfCalled(It.Is<IUserDTO>(x =>  x.LastName == "3" & x.FirstName == "2")));
like image 45
Code First Avatar answered Oct 21 '22 06:10

Code First


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

check_description = () => mockKoko.Verify(x => x.Koko(It.IsAny<ComplexType>()), Times.Once());
like image 61
levelnis Avatar answered Oct 21 '22 07:10

levelnis