-
-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returns not working on UdpClient.Receive() method. #439
Comments
I am not sure that I understand how your two repro code blocks are supposed to work and be related to one another. It seems incomplete. Could you please post a minimally complete code example that leads to the error message you're describing? |
In absence of actual repro code, I will just guess you're doing something like the following (which produces the same error): public interface IUdpClientExtended
{
byte[] Receive(ref IPEndPoint endpoint);
}
var mock = new Mock<IUdpClientExtended>(MockBehavior.Strict);
var endpoint = new IPEndPoint(IPAddress.Any, 0);
mock.Setup(_ => _.Receive(ref endpoint)).Returns(Encoding.UTF8.GetBytes("Hello world"));
var differentEndpoint = new IPEndPoint(IPAddress.Any, 0);
var response = mock.Object.Receive(ref differentEndpoint); This doesn't work because the instance of AFAIK, Moq doesn't currently support
If the above doesn't help you, or my repro code doesn't match your scenario, please report back and we can reopen this issue. |
Returns not working on UdpClient.Receive() method.
Class code:
Unit testing code:
Nothing is returned (byte[]). Exception is "The following setups were not matched:
IUdpClientExtended x => x.Receive(0.0.0.0:0)". It is also problem with replacing Returns with Throws.
With Strict mode, the error says: "Invocation failed with mock behavior Strict. All invocations on the mock must have a corresponding setup."
The text was updated successfully, but these errors were encountered: