jeudi 30 juillet 2015

Moq Callback is fine in first test, but same code returns null in second test

Would anyone know why, when using moq in 2 tests I have the following code:

var magentoChannelMock = new Mock<IMagentoChannel>();

var magentoChannelMock = new Mock<IMagentoChannel>();

magentoChannelMock.Setup(x => x.SalesOrderInvoiceCreate(It.IsAny<string>(), "2", It.IsAny<orderItemIdQty[]>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
                .Callback<string, string, orderItemIdQty[], string, string, string>((s1, s2, x, s3, s4, s5) => invoicesSent = x);

I have 2 tests in a test class, when I run each individually, they run fine and the callback object "invoicesSent" contains the expected value. But when I run both tests at the same time, the second test that is run always gets null returned as the callback.

Any idea?

Aucun commentaire:

Enregistrer un commentaire