Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit 0e33f70

Browse files
peterfeltshathind-ms
authored andcommitted
Fixing a bug that was causing property updates to not be sent. (#311)
1 parent 01cfbcf commit 0e33f70

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

SimulationAgent.Test/DeviceProperties/DevicePropertiesActorTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class DevicePropertiesActorTest
2525
private readonly Mock<ILogger> logger;
2626
private readonly Mock<IActorsLogger> actorsLogger;
2727
private readonly Mock<CredentialsSetup> credentialSetup;
28-
private readonly Mock<IRateLimiting> rateLimiting;
28+
private readonly Mock<IRateLimiting> mockRateLimiting;
2929
private readonly Mock<IRateLimitingConfig> rateLimitingConfig;
3030
private readonly Mock<IDevices> devices;
3131
private readonly Mock<IStorageAdapterClient> storageAdapterClient;
@@ -46,7 +46,7 @@ public DevicePropertiesActorTest(ITestOutputHelper log)
4646
{
4747
this.logger = new Mock<ILogger>();
4848
this.actorsLogger = new Mock<IActorsLogger>();
49-
this.rateLimiting = new Mock<IRateLimiting>();
49+
this.mockRateLimiting = new Mock<IRateLimiting>();
5050
this.credentialSetup = new Mock<CredentialsSetup>();
5151
this.rateLimitingConfig = new Mock<IRateLimitingConfig>();
5252
this.mockDeviceContext = new Mock<IDeviceConnectionActor>();
@@ -151,7 +151,7 @@ private void CreateNewDevicePropertiesActor()
151151
this.target = new DevicePropertiesActor(
152152
this.logger.Object,
153153
this.actorsLogger.Object,
154-
this.rateLimiting.Object,
154+
this.mockRateLimiting.Object,
155155
this.updatePropertiesLogic.Object,
156156
this.deviceTagLogic.Object,
157157
this.mockInstance.Object);
@@ -164,6 +164,7 @@ private void SetupDevicePropertiesActor()
164164
var mockSimulationContext = new Mock<ISimulationContext>();
165165
mockSimulationContext.Object.InitAsync(testSimulation).Wait(Constants.TEST_TIMEOUT);
166166
mockSimulationContext.SetupGet(x => x.Devices).Returns(this.devices.Object);
167+
mockSimulationContext.SetupGet(x => x.RateLimiting).Returns(this.mockRateLimiting.Object);
167168

168169
this.target.Init(
169170
mockSimulationContext.Object,

SimulationAgent/DeviceProperties/DevicePropertiesActor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ private void SchedulePropertiesUpdate(bool isRetry = false)
270270
{
271271
// considering the throttling settings, when can the properties be updated
272272
var now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
273-
var pauseMsec = this.rateLimiting.GetPauseForNextTwinWrite();
273+
var pauseMsec = this.simulationContext.RateLimiting.GetPauseForNextTwinWrite();
274274
this.whenToRun = now + pauseMsec;
275275
this.status = ActorStatus.ReadyToUpdate;
276276

@@ -289,7 +289,7 @@ private void ScheduleDeviceTagging()
289289
{
290290
var now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
291291
// note: we overwrite the twin, so no Read operation is needed
292-
var pauseMsec = this.rateLimiting.GetPauseForNextTwinWrite();
292+
var pauseMsec = this.simulationContext.RateLimiting.GetPauseForNextTwinWrite();
293293
this.whenToRun = now + pauseMsec;
294294
this.status = ActorStatus.ReadyToTagDevice;
295295

0 commit comments

Comments
 (0)