From 7294029ccbcb4bfb8d5cb290ab80ca7b3347711e Mon Sep 17 00:00:00 2001 From: "Beaugrand, Kevin" Date: Mon, 28 Feb 2022 15:24:25 +0100 Subject: [PATCH] Add unit test to GetDevicesConfigurations --- .../Services/ConfigsServicesTests.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/AzureIoTHub.Portal.Server.Tests.Unit/Services/ConfigsServicesTests.cs b/src/AzureIoTHub.Portal.Server.Tests.Unit/Services/ConfigsServicesTests.cs index dbf38624f..a3d7bb6c6 100644 --- a/src/AzureIoTHub.Portal.Server.Tests.Unit/Services/ConfigsServicesTests.cs +++ b/src/AzureIoTHub.Portal.Server.Tests.Unit/Services/ConfigsServicesTests.cs @@ -30,7 +30,7 @@ private ConfigService CreateConfigsServices() } [Test] - public async Task GetAllConfigs_StateUnderTest_ExpectedBehavior() + public async Task GetIoTEdgeConfigs_Should_Return_Modules_Configurations() { // Arrange var configsServices = this.CreateConfigsServices(); @@ -51,6 +51,33 @@ public async Task GetAllConfigs_StateUnderTest_ExpectedBehavior() Assert.IsNotNull(result); Assert.AreEqual(1, result.Count()); Assert.AreEqual("bbb", result.Single().Id); + + this.mockRepository.VerifyAll(); + } + + [Test] + public async Task GetDevicesConfigs_Should_Return_DeviceTwin_Configurations() + { + // Arrange + var configsServices = this.CreateConfigsServices(); + var iotEdgeConfiguration = new Configuration("bbb"); + + iotEdgeConfiguration.Content.ModulesContent.Add("test", new Dictionary()); + this.mockRegistryManager.Setup(c => c.GetConfigurationsAsync(It.Is(x => x == 0))) + .ReturnsAsync(new[] + { + new Configuration("aaa"), + iotEdgeConfiguration + }); + + // Act + var result = await configsServices.GetDevicesConfigurations(); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(1, result.Count()); + Assert.AreEqual("aaa", result.Single().Id); + this.mockRepository.VerifyAll(); }