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

Commit

Permalink
Fixing a bug that was causing property updates to not be sent. (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfelts authored and hathind-ms committed Nov 7, 2018
1 parent 01cfbcf commit 0e33f70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class DevicePropertiesActorTest
private readonly Mock<ILogger> logger;
private readonly Mock<IActorsLogger> actorsLogger;
private readonly Mock<CredentialsSetup> credentialSetup;
private readonly Mock<IRateLimiting> rateLimiting;
private readonly Mock<IRateLimiting> mockRateLimiting;
private readonly Mock<IRateLimitingConfig> rateLimitingConfig;
private readonly Mock<IDevices> devices;
private readonly Mock<IStorageAdapterClient> storageAdapterClient;
Expand All @@ -46,7 +46,7 @@ public DevicePropertiesActorTest(ITestOutputHelper log)
{
this.logger = new Mock<ILogger>();
this.actorsLogger = new Mock<IActorsLogger>();
this.rateLimiting = new Mock<IRateLimiting>();
this.mockRateLimiting = new Mock<IRateLimiting>();
this.credentialSetup = new Mock<CredentialsSetup>();
this.rateLimitingConfig = new Mock<IRateLimitingConfig>();
this.mockDeviceContext = new Mock<IDeviceConnectionActor>();
Expand Down Expand Up @@ -151,7 +151,7 @@ private void CreateNewDevicePropertiesActor()
this.target = new DevicePropertiesActor(
this.logger.Object,
this.actorsLogger.Object,
this.rateLimiting.Object,
this.mockRateLimiting.Object,
this.updatePropertiesLogic.Object,
this.deviceTagLogic.Object,
this.mockInstance.Object);
Expand All @@ -164,6 +164,7 @@ private void SetupDevicePropertiesActor()
var mockSimulationContext = new Mock<ISimulationContext>();
mockSimulationContext.Object.InitAsync(testSimulation).Wait(Constants.TEST_TIMEOUT);
mockSimulationContext.SetupGet(x => x.Devices).Returns(this.devices.Object);
mockSimulationContext.SetupGet(x => x.RateLimiting).Returns(this.mockRateLimiting.Object);

this.target.Init(
mockSimulationContext.Object,
Expand Down
4 changes: 2 additions & 2 deletions SimulationAgent/DeviceProperties/DevicePropertiesActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private void SchedulePropertiesUpdate(bool isRetry = false)
{
// considering the throttling settings, when can the properties be updated
var now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
var pauseMsec = this.rateLimiting.GetPauseForNextTwinWrite();
var pauseMsec = this.simulationContext.RateLimiting.GetPauseForNextTwinWrite();
this.whenToRun = now + pauseMsec;
this.status = ActorStatus.ReadyToUpdate;

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

Expand Down

0 comments on commit 0e33f70

Please sign in to comment.