diff --git a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj index d0684cf..6dc1664 100644 --- a/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj +++ b/src/CaseOnline.Azure.WebJobs.Extensions.Mqtt/CaseOnline.Azure.WebJobs.Extensions.Mqtt.csproj @@ -9,7 +9,7 @@ https://github.com/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt git https://github.com/keesschollaart81/CaseOnline.Azure.WebJobs.Extensions.Mqtt/blob/master/LICENSE - 0.0.1 + 0.0.2 beta azure functions mqtt webjobs trigger binding function webjob CaseOnline.Azure.WebJobs.Extensions.Mqtt diff --git a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/IntegrationTests.cs b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/IntegrationTests.cs index a8a561f..4868250 100644 --- a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/IntegrationTests.cs +++ b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/IntegrationTests.cs @@ -59,20 +59,29 @@ public static void Testert([MqttTrigger("test/topic")] PublishedMqttMessage publ } [Fact] - public async Task CustomConnectionStringIsReceived() + public async Task CustomConnectionWithClientIdIsReceived() { - using (var mqttServer = await MqttServerHelper.Get(_logger)) - using (var jobHost = await JobHostHelper.RunFor(_loggerFactory)) + string clientId = string.Empty; + var options = new MqttServerOptionsBuilder() + .WithConnectionValidator(x => + { + clientId = x.ClientId; + }) + .Build(); + + using (var mqttServer = await MqttServerHelper.Get(_logger, options)) + using (var jobHost = await JobHostHelper.RunFor(_loggerFactory)) { await mqttServer.PublishAsync(DefaultMessage); - await jobHost.WaitFor(() => CustomConnectionStringTestFunction.CallCount >= 1); + await jobHost.WaitFor(() => CustomConnectionStringWithClientIdTestFunction.CallCount >= 1); } - Assert.Equal(1, CustomConnectionStringTestFunction.CallCount); + Assert.Equal(1, CustomConnectionStringWithClientIdTestFunction.CallCount); + Assert.Equal("Custom", clientId); } - private class CustomConnectionStringTestFunction + private class CustomConnectionStringWithClientIdTestFunction { public static int CallCount = 0; public static PublishedMqttMessage LastReceivedMessage; diff --git a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/appsettings.json b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/appsettings.json index 10917ed..b065e3d 100644 --- a/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/appsettings.json +++ b/test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/appsettings.json @@ -2,7 +2,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "AzureWebJobsDashboard": "UseDevelopmentStorage=true", "MqttConnection": "Server=localhost", - "CustomMqttConnection": "Server=localhost", + "CustomMqttConnection": "Server=localhost;ClientId=Custom", "MqttConnectionWithCustomPort": "Server=localhost;Port=1337", "MqttConnectionWithUsernameAndPassword": "Server=localhost;Username=admin;Password=Welkom123" } \ No newline at end of file