Skip to content

Commit e4080a7

Browse files
Copilotkbeaugrand
andcommitted
Fix test failures: remove IDeviceClientService injection and add GetPlanning mocks
Co-authored-by: kbeaugrand <9513635+kbeaugrand@users.noreply.github.com>
1 parent 7f300bf commit e4080a7

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/IoTHub.Portal.Client/Components/Planning/EditPlanning.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
@inject ILayerClientService LayerClientService
88
@inject IDeviceModelsClientService DeviceModelsClientService
99
@inject ILoRaWanDeviceModelsClientService LoRaWanDeviceModelsClientService
10-
@inject IDeviceClientService DeviceClientService
1110
@inject IDialogService DialogService
1211
@inject ISnackbar Snackbar
1312

src/IoTHub.Portal.Tests.Unit/Client/Dialogs/Layer/LinkDeviceLayerDialogTest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public async Task LinkDeviceLayerDialog_Search_RendersCorrectlyAsync()
4040
var searchedDevices = Fixture.CreateMany<TableData<DeviceListItem>>(3).ToList();
4141
var expectedLayerDto = Fixture.Create<LayerDto>();
4242

43+
// Setup GetPlanning mock to handle any planning ID (in case the fixture creates one)
44+
_ = this.mockPlanningClientService.Setup(service => service.GetPlanning(It.IsAny<string>()))
45+
.ReturnsAsync(new PlanningDto { DeviceModelId = null });
46+
4347
_ = this.mockDeviceClientService.Setup(service =>
4448
service.GetDevices($"{this.apiBaseUrl}?pageNumber=0&pageSize=5&searchText="))
4549
.ReturnsAsync(new PaginationResult<DeviceListItem>
@@ -84,6 +88,9 @@ public async Task LinkDeviceLayerDialog_Search_ShouldDisplayDevicesAsync()
8488
Name = Guid.NewGuid().ToString()
8589
};
8690

91+
// Setup GetPlanning mock to handle any planning ID (in case the fixture creates one)
92+
_ = this.mockPlanningClientService.Setup(service => service.GetPlanning(It.IsAny<string>()))
93+
.ReturnsAsync(new PlanningDto { DeviceModelId = null });
8794

8895
_ = this.mockDeviceClientService.Setup(service =>
8996
service.GetDevices($"{this.apiBaseUrl}?pageNumber=0&pageSize=5&searchText="))
@@ -140,6 +147,9 @@ public async Task LinkDeviceLayerDialog_Save_UpdatesDevices()
140147
Name = Guid.NewGuid().ToString()
141148
};
142149

150+
// Setup GetPlanning mock to handle any planning ID (in case the fixture creates one)
151+
_ = this.mockPlanningClientService.Setup(service => service.GetPlanning(It.IsAny<string>()))
152+
.ReturnsAsync(new PlanningDto { DeviceModelId = null });
143153

144154
_ = this.mockDeviceClientService.Setup(service =>
145155
service.GetDevices($"{this.apiBaseUrl}?pageNumber=0&pageSize=5&searchText="))
@@ -270,6 +280,10 @@ public async Task LinkDeviceLayerDialog_Save_UpdatesDevicesFromMultiplePages()
270280
Name = Guid.NewGuid().ToString()
271281
};
272282

283+
// Setup GetPlanning mock to handle any planning ID (in case the fixture creates one)
284+
_ = this.mockPlanningClientService.Setup(service => service.GetPlanning(It.IsAny<string>()))
285+
.ReturnsAsync(new PlanningDto { DeviceModelId = null });
286+
273287
// Simulate device on first page (device not yet assigned to any layer)
274288
var device1 = new DeviceListItem
275289
{

0 commit comments

Comments
 (0)