-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing the name resolver for custom config provider (addresses #12)
- Loading branch information
1 parent
b35390b
commit 3641511
Showing
7 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/MqttConfigExample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using CaseOnline.Azure.WebJobs.Extensions.Mqtt.Config; | ||
using MQTTnet.Extensions.ManagedClient; | ||
|
||
namespace CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests.Helpers | ||
{ | ||
public class MqttConfigExample : CustomMqttConfig | ||
{ | ||
public override IManagedMqttClientOptions Options { get; } | ||
|
||
public override string Name { get; } | ||
|
||
public MqttConfigExample(string name, IManagedMqttClientOptions options) | ||
{ | ||
Options = options; | ||
Name = name; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
test/CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests/Helpers/TestMqttConfigProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Extensions.Logging; | ||
using MQTTnet.Extensions.ManagedClient; | ||
using MQTTnet.Client; | ||
using CaseOnline.Azure.WebJobs.Extensions.Mqtt.Config; | ||
using CaseOnline.Azure.WebJobs.Extensions.Mqtt.Bindings; | ||
|
||
namespace CaseOnline.Azure.WebJobs.Extensions.Mqtt.Tests.Helpers | ||
{ | ||
public class TestMqttConfigProvider : ICreateMqttConfig | ||
{ | ||
public CustomMqttConfig Create(INameResolver nameResolver, ILogger logger) | ||
{ | ||
var connectionString = new MqttConnectionString(nameResolver.Resolve("MqttConnectionWithCustomClientId")); | ||
|
||
var options = new ManagedMqttClientOptionsBuilder() | ||
.WithAutoReconnectDelay(TimeSpan.FromSeconds(5)) | ||
.WithClientOptions(new MqttClientOptionsBuilder() | ||
.WithClientId(connectionString.ClientId.ToString()) | ||
.WithTcpServer(connectionString.Server, connectionString.Port) | ||
.WithCredentials(connectionString.Username, connectionString.Password) | ||
.Build()) | ||
.Build(); | ||
|
||
|
||
return new MqttConfigExample("CustomConnection", options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters