c# - Moq confusion - Setup() v Setup<>() -
i have mock being created this:
var mock = new mock<ipacket>(mockbehavior.strict); mock.setup(p => p.getbytes()).returns(new byte[] { }).verifiable();
the intellisense setup method says this:
"specifies setup on mocked type call void returning method."
but mocked method p.getbytes() not return void, returns byte array.
alternatively setup method defined setup<>, , can create mock this:
var mock = new mock<ipacket>(mockbehavior.strict); mock.setup<byte[]>(p => p.getbytes()).returns(new byte[] { }).verifiable();
the intellisense of setup method states:
"specifies setup on mocked type call value returning method."
.
.
whichever method choose, compiles , tests ok. so, i'm confused way should doing this. difference between .setup() , .setup<>(), , doing right?
the docs moq lacking, shall say. :)
the compiler inferring lambda passed setup()
meant call generic version, , happily infers generic argument you. if use reflector see first code example in fact calling setup<byte[]>()
.
Comments
Post a Comment