protected virtual async Task <IMqttClient> GetClientAsync() { var binding = new TcpBinding(); var initializer = new MqttClientFactory(IPAddress.Loopback.ToString(), binding); if (Configuration == null) { LoadConfiguration(); } return(await initializer.CreateClientAsync(Configuration)); }
public async Task when_initializing_client_then_succeeds() { var port = new Random().Next(IPEndPoint.MinPort, IPEndPoint.MaxPort); var listener = new TcpListener(IPAddress.Loopback, port); listener.Start(); var configuration = new MqttConfiguration { BufferSize = 131072, Port = port }; var binding = new TcpBinding(); var initializer = new MqttClientFactory(IPAddress.Loopback.ToString(), binding); var client = await initializer.CreateClientAsync(configuration); Assert.NotNull(client); listener.Stop(); }