Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I Moq It.IsAny for an array in the setup of a method?

I'm brand new to Moq (using v 4) and am struggling a little with the documentation.

What I'm trying to do is to Moq a method that takes a byte array and returns an object. Something like:

decoderMock.Setup(d => d.Decode(????).Returns(() => tagMock.Object);

The ???? is where the byte[] should be, but I can't work out how to make it so that I don't care what's in the byte array, just return the mocked object I've already set up.

Moq.It.IsAny expects a generic.

Any help please?

like image 314
Graham Avatar asked Mar 18 '10 17:03

Graham


2 Answers

It.IsAny<byte[]>()

??

like image 96
pms1969 Avatar answered Oct 06 '22 13:10

pms1969


Setup Method With Params Array

mock.Setup(m => m.GetFirstTicketInQueueIfMatches(It.IsAny<string[]>()))
like image 24
joembraun Avatar answered Oct 06 '22 12:10

joembraun