1- using System . Security . Cryptography . X509Certificates ;
21using Fg . IoTEdgeModule . Configuration ;
32using Microsoft . Azure . Devices . Client ;
43using Microsoft . Azure . Devices . Shared ;
@@ -11,7 +10,7 @@ public class ModuleConfigurationTests : IClassFixture<EnvironmentFixture>
1110 {
1211 public ModuleConfigurationTests ( EnvironmentFixture environmentFixture )
1312 {
14-
13+
1514 }
1615
1716 [ Fact ]
@@ -25,18 +24,35 @@ var config
2524 Assert . NotNull ( config ) ;
2625 }
2726
27+ [ Fact ]
28+ public void CanInitializeConfiguration ( )
29+ {
30+ var desiredProperties = new TwinCollection ( """{"SomeIntProperty":42, "SomeStringProperty": "stringvalue"}""" ) ;
31+
32+ var config = ModuleConfiguration . CreateFromTwin < TestModuleConfiguration > ( desiredProperties , NullLogger . Instance ) ;
33+
34+ Assert . Equal ( 42 , config . SomeIntProperty ) ;
35+ Assert . Equal ( "stringvalue" , config . SomeStringProperty ) ;
36+ }
37+
2838 private class TestModuleConfiguration : ModuleConfiguration
2939 {
30- public TestModuleConfiguration ( ILogger logger ) : base ( logger ) { }
40+ public TestModuleConfiguration ( ILogger logger ) : base ( logger ) { }
41+
3142 protected override string ModuleName => "TestModule" ;
43+
44+ public int SomeIntProperty { get ; private set ; }
45+ public string SomeStringProperty { get ; private set ; }
46+
3247 protected override void InitializeFromTwin ( TwinCollection desiredProperties )
3348 {
34- int x = desiredProperties . Count ;
49+ SomeIntProperty = desiredProperties [ "SomeIntProperty" ] ;
50+ SomeStringProperty = desiredProperties [ "SomeStringProperty" ] ;
3551 }
3652
3753 protected override void SetReportedProperties ( TwinCollection reportedProperties )
3854 {
39-
55+
4056 }
4157 }
4258 }
0 commit comments