An open API service indexing awesome lists of open source software.

https://github.com/vforteli/flexinets.net.udpclient


https://github.com/vforteli/flexinets.net.udpclient

mock netstandard testing udp-client

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

Flexinets.Net.IUdpClient

The purpose of the mock UdpClient is to test receiveing and sending UDP packets.
Currently it is only designed for limited use cases where a server receive an UDP packet, and then responds to it using the same UdpClient.

Usage
```
var expected = "test";
var bytes = Encoding.UTF8.GetBytes(expected);

var client = new UdpClientMock();
var factory = new UdpClientMockFactory(client);

var task = factory.CreateClient(null).ReceiveAsync();

// This will wait until some other thread sends a response to the same udpclient
var response = await client.SendMock(new UdpReceiveResult(bytes, new IPEndPoint(IPAddress.Any, 1812)));

var actual = Encoding.UTF8.GetString(response.Buffer);

Assert.AreEqual(expected, actual);