Skip to content

Commit

Permalink
fix(iot-svc): update debug assert (#2264)
Browse files Browse the repository at this point in the history
* fix(iot-svc): update debug assert

* Temporarily disable import devices/configs test (#2263)

* fix(iot-svc): update debug assert

* Reduce modules in ModulesClient_GetModulesOnDevice to 2
  • Loading branch information
David R. Williamson authored Jan 6, 2022
1 parent 2b05e47 commit 89973ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions e2e/test/iothub/service/RegistryManagerE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public async Task RegistryManager_Query_Works()
[LoggedTestMethod]
public async Task ModulesClient_GetModulesOnDevice()
{
int moduleCount = 5;
const int moduleCount = 2;
string testDeviceId = $"IdentityLifecycleDevice{Guid.NewGuid()}";
string[] testModuleIds = new string[moduleCount];
for (int i = 0; i < moduleCount; i++)
Expand All @@ -440,6 +440,9 @@ public async Task ModulesClient_GetModulesOnDevice()
new Module(testDeviceId, testModuleIds[i])).ConfigureAwait(false);
}

// Give the hub a moment
await Task.Delay(250).ConfigureAwait(false);

// List the modules on the test device
IEnumerable<Module> modulesOnDevice = await client.GetModulesOnDeviceAsync(testDeviceId).ConfigureAwait(false);

Expand All @@ -450,7 +453,7 @@ public async Task ModulesClient_GetModulesOnDevice()
Assert.AreEqual(moduleCount, moduleIdsOnDevice.Count);
for (int i = 0; i < moduleCount; i++)
{
Assert.IsTrue(moduleIdsOnDevice.Contains(testModuleIds[i]));
moduleIdsOnDevice.Should().Contain(testModuleIds[i]);
}
}
finally
Expand Down
7 changes: 5 additions & 2 deletions iothub/device/src/IotHubConnectionString.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ Task<string> IAuthorizationProvider.GetPasswordAsync()
if (Logging.IsEnabled)
Logging.Enter(this, $"{nameof(IotHubConnectionString)}.{nameof(IAuthorizationProvider.GetPasswordAsync)}");

Debug.Assert(TokenRefresher != null);
Debug.Assert(
!string.IsNullOrWhiteSpace(SharedAccessSignature)
|| TokenRefresher != null,
"The token refresher and the shared access signature can't both be null");

return !string.IsNullOrWhiteSpace(SharedAccessSignature)
? Task.FromResult(SharedAccessSignature)
: TokenRefresher.GetTokenAsync(Audience);
: TokenRefresher?.GetTokenAsync(Audience);
}
finally
{
Expand Down

0 comments on commit 89973ed

Please sign in to comment.