public async Task CanGetClient() { var logger = new Mock <ILogger <AssuredMqttConnection> >(); var mqttClient = new Mock <IManagedMqttClient>(); var mqttFactory = new MqttFactoryWrapper(mqttClient.Object); var conn = new AssuredMqttConnection(logger.Object, mqttFactory, GetMockOptions()); var returnedClient = await conn.GetClientAsync(); returnedClient.Should().Be(mqttClient.Object); }
/// <summary> /// Get a mocked MQTT client, factor and connection /// </summary> /// <returns></returns> private void SetupMockMqtt() { var options = new Mock <IOptions <MqttConfiguration> >(); options.Setup(o => o.Value) .Returns(() => new MqttConfiguration { Host = "localhost", UserName = "******" }); MqttClient = new Mock <IManagedMqttClient>(); MqttFactory = new MqttFactoryWrapper(MqttClient.Object); Connection = new AssuredMqttConnection(new Mock <ILogger <AssuredMqttConnection> >().Object, MqttFactory, options.Object); }