How do I unit test Service Bus SendAsync method properly?

Solution 1:

Instead of creating a new message object which wouldn't work because the references are different - you could decode the body property from the Message class and verify the customer object's properties.

Solution 2:

Instead of doing an object comparison (which is what Moq is doing), you can do the verification that the object being passed to the method has specific properties of the object using It.Is<T>.

_queueClient.Verify(t = > t.SendAsync(It.Is<byte[]>(x => x.Body == Encoding.UTF8.GetBytes(messageBody)));