This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor code writing twin tags for better performance * Refactor device properties code for better performance * Refactor simulation runner for better performance * Improve connections performance * Reduce time to start simulation, by creating devices using the same conn string and fetching device from registry only if the authentication fails. * Limit the number of pending threads attempting to deliver telemetry * Change all stock device models to use AMQP * Move SDK timeout setting and other hard coded magic numbers to config file * Use default timeout value from SDK instead of hardcoding it * Improve documentation in the configuration file * Upgrade IoT SDK * Improve logging in device client * Reduce noise in the "Info" log level * When building, remove "deleted files" left over from previous builds * Improve error detection when creating devices with batch operations * Recreate device client when the internal AMQP client is disposed (lib bug workaround) * VS code config update * Remove simulation version, not used anywhere * Catch and log when a device model doesn't exist * Log missing config settings * Make sure the simulation object is not lost in case of errors while checking for simulation changes * Limit async tests duration * Remove IoT hub registry workaround * Fix boolean conf values parsing * Remove "en-us" from links in the comments * Fix invalid parsing of environment variables
- Loading branch information
Showing
94 changed files
with
1,957 additions
and
846 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using Microsoft.Azure.Devices.Client.Exceptions; | ||
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services; | ||
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Diagnostics; | ||
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Exceptions; | ||
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.IotHub; | ||
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Models; | ||
using Moq; | ||
using Services.Test.helpers; | ||
using Xunit; | ||
|
||
namespace Services.Test | ||
{ | ||
public class DeviceClientTest | ||
{ | ||
private readonly DeviceClient target; | ||
private readonly Mock<IDeviceClientWrapper> client; | ||
private readonly Mock<IDeviceMethods> deviceMethods; | ||
private readonly Mock<ILogger> log; | ||
|
||
public DeviceClientTest() | ||
{ | ||
this.client = new Mock<IDeviceClientWrapper>(); | ||
this.deviceMethods = new Mock<IDeviceMethods>(); | ||
this.log = new Mock<ILogger>(); | ||
|
||
this.target = new DeviceClient( | ||
"x", | ||
IoTHubProtocol.AMQP, | ||
this.client.Object, | ||
this.deviceMethods.Object, | ||
this.log.Object); | ||
} | ||
|
||
[Fact, Trait(Constants.TYPE, Constants.UNIT_TEST)] | ||
public void ConnectsToIoTHub() | ||
{ | ||
// Act (connect twice, the second call should be ignored) | ||
this.target.ConnectAsync().Wait(Constants.TEST_TIMEOUT); | ||
this.target.ConnectAsync().Wait(Constants.TEST_TIMEOUT); | ||
|
||
// Assert | ||
this.client.Verify(x=>x.OpenAsync(), Times.Once); | ||
} | ||
|
||
[Fact, Trait(Constants.TYPE, Constants.UNIT_TEST)] | ||
public void AuthFailureOnConnectRaiseException() | ||
{ | ||
// Arrange | ||
this.client.Setup(x => x.OpenAsync()).Throws(new UnauthorizedException("")); | ||
|
||
// Act + Assert | ||
Assert.ThrowsAsync<DeviceAuthFailedException>( | ||
async () => await this.target.ConnectAsync()).Wait(Constants.TEST_TIMEOUT); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.