Proxy Calls Received argument evaluation / string parameter Question

31 views
Skip to first unread message

Luc Debliquis

unread,
Mar 1, 2018, 2:07:59 PM3/1/18
to NSubstitute
Hello,

Can someone explain me why the first test is passing, while the second one is failing.
(the message is not modified at all in the _ips.ProcessRequest())
I guess that's linked with the way Nsubsitute evaluates the calls..


Thanks


[TestMethod, TestCategory("ips-22")]
public void ProcessRequest_ValidMessage_LogsInfo()
{
   
var message = new CloudQueueMessage(_validMessageRequest);
   
var rawMessage = message.AsString;
 
    _ips
.ProcessRequest(message, _inboundQueue).Wait();
 
   
// validates that the logger gets a call on info, with the message contents in
    _logger
.Received(1).Info(Arg.Is<string>(s => s.Contains(rawMessage)));
}
 
[TestMethod, TestCategory("ips-22")]
public void ProcessRequest_ValidMessage_LogsInfo2()
{
   
var message = new CloudQueueMessage(_validMessageRequest);
   
//var rawMessage = message.AsString;
 
    _ips
.ProcessRequest(message, _inboundQueue).Wait();
 
   
// validates that the logger gets a call on info, with the message contents in
    _logger
.Received(1).Info(Arg.Is<string>(s => s.Contains(message.AsString)));
}


Luc Debliquis

unread,
Mar 1, 2018, 2:10:48 PM3/1/18
to NSubstitute
in the second test, the proxy expects to receive this

NSubstitute.Exceptions.ReceivedCallsException: Expected to receive exactly 1 call matching:
Info(s => s.Contains(value(IPS.ServiceTests.IPSServiceTests_ProcessRequest+<>c__DisplayClass43_0).message.AsString))
Actually received no matching calls. 

=> he received, as expected, the string value of the message object

David Tchepak

unread,
Mar 1, 2018, 5:35:00 PM3/1/18
to nsubs...@googlegroups.com
Hi Luc,

Does `message.AsString` call another substitute? (the `_validMessageRequest` maybe?) NSubstitute can get confused sometimes if calls are nested, but I'm not sure this is the case here.

If possible would you be able to post a complete failing example to GitHub issues: https://github.com/nsubstitute/NSubstitute/issues ? It is fine to simplify it and remove any private information, we just need enough for us to be able to run a test and get a similar failure to the one you are noticing.

Regards,
David




--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nsubstitute+unsubscribe@googlegroups.com.
To post to this group, send email to nsubs...@googlegroups.com.
Visit this group at https://groups.google.com/group/nsubstitute.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages