lundi 1 août 2016

Capturing argument with NSubstitute for dynamic types

Using NSubstitute with XUnit and a dynamic type.

I am trying to capture the passed argument, using the following syntax:

// Arrange
SendGridAPIClient s = Substitute.For<SendGridAPIClient>("ARandomKeyHere", 
    "http://ift.tt/1l3MS84", "v3");
string mailContent = null;
// Note that "client" is a dynamic type
s.client.mail.send.post(RequestBody: Arg.Do<string>(x => mailContent = x));

The value of mailContent is not captured in the Arg.Do. I am not sure what the reason is, but my best bet is that it is due to the usage of dynamic type.

Has anybody experienced this before? Do you have any solution to capture the passed argument when you have a dynamic type?

Aucun commentaire:

Enregistrer un commentaire