c# - ToArray doesn't seem to be working Moq's Verify method -


i'm trying verify method call using moq following code.

var _payload= new list<keyvaluepair<string, object>> {     new keyvaluepair<string, object>("test", testnum),     new keyvaluepair<string, object>("firstruntime", datetime.parse("19-apr-2001 09:30:00")) }; 

the above list definition common both following pieces of code. i'd tried this::

mockmessageprocessor.verify(service => service.queuemessage(     datetime.parse("19-apr-2016 10:05:00"),      "testjobkey",     _payload.toarray()), times.once); 

this fails saying there no invocation of above method parameters. putting same thing in variable works.

var payloadarray = _payload.toarray(); mockmessageprocessor.verify(service => service.queuemessage(     datetime.parse("19-apr-2016 10:05:00"),      "testjobkey",     payloadarray), times.once); 

the above verify works. wanted know why happening.

quoting aron comment above:

because equals(_payload.toarray(), _payload.toarray() == false whilst equals(payloadarray, payloadarray) == true


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -