Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeM-2ISA authored and hocinehacherouf committed Apr 7, 2023
1 parent 5525151 commit 5b4a4cb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
{
if (IsLoRa)
{
<MudTabPanel id="tab-lorawan" Text="LoRaWAN" Style=@(this.CheckLoRaValidation() ? "color: red": "")>
<MudTabPanel Text="LoRaWAN" Style=@(this.CheckLoRaValidation() ? "color: red": "")>
<CreateLoraDevice LoRaDevice="@(Device as LoRaDeviceDetails)" LoraModelDto="@(LoRaDeviceModelDto)" LoraValidator="@(loraValidator)" />
</MudTabPanel>
}
Expand All @@ -339,7 +339,7 @@
{
if (IsLoRa && Device != null && Commands != null)
{
<MudTabPanel id="tab-lorawan" Text="LoRaWAN" Style=@(this.CheckLoRaValidation() ? "color: red": "")>
<MudTabPanel Text="LoRaWAN" Style=@(this.CheckLoRaValidation() ? "color: red": "")>
<EditLoraDevice LoRaDevice="@(Device as LoRaDeviceDetails)" LoraValidator="@(loraValidator)" LoRaDeviceModelDto="@(DeviceModel as LoRaDeviceModelDto)" Commands="@Commands" />
</MudTabPanel>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace AzureIoTHub.Portal.Tests.Unit.Client.Components.Devices
using AzureIoTHub.Portal.Client.Models;
using AzureIoTHub.Portal.Client.Services;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Models.v10.LoRaWAN;
using AzureIoTHub.Portal.Shared.Models;
using AzureIoTHub.Portal.Shared.Models.v1._0;
using AzureIoTHub.Portal.Shared.Models.v10.Filters;
using AzureIoTHub.Portal.Tests.Unit.UnitTests.Bases;
using AzureIoTHub.Portal.Tests.Unit.UnitTests.Mocks;
Expand Down Expand Up @@ -726,33 +728,36 @@ public async Task DisplayPropertiesRenderCorrectly()
cut.WaitForAssertion(() => MockRepository.VerifyAll());
}

//[Test]
//public async Task DisplayCreateLoraDeviceComponentRenderCorrectly()
//{
// // Arrange
// var mockDeviceModel = new DeviceModelDto
// {
// ModelId = Guid.NewGuid().ToString(),
// Description = Guid.NewGuid().ToString(),
// SupportLoRaFeatures = true,
// Name = Guid.NewGuid().ToString()
// };

// _ = this.mockDeviceTagSettingsClientService.Setup(service => service.GetDeviceTags())
// .ReturnsAsync(new List<DeviceTagDto>());

// _ = this.mockLoRaWanDeviceModelsClientService
// .Setup(service => service.GetDeviceModel(It.IsAny<string>()))
// .ReturnsAsync(new LoRaDeviceModelDto());

// var cut = RenderComponent<EditDevice>(parameters => parameters.Add(p => p.context, CreateEditMode.Create));

// // Act
// await cut.Instance.ChangeModel(mockDeviceModel);
// _ = cut.WaitForElement("#tab-lorawan");

// // Assert
// cut.WaitForAssertion(() => cut.Find("#tab-lorawan").TextContent.Should().Be("LoRaWAN"));
//}
[Test]
public async Task DisplayCreateLoraDeviceComponentRenderCorrectly()
{
// Arrange
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
SupportLoRaFeatures = true,
Name = Guid.NewGuid().ToString()
};

_ = this.mockDeviceTagSettingsClientService.Setup(service => service.GetDeviceTags())
.ReturnsAsync(new List<DeviceTagDto>());

_ = this.mockLoRaWanDeviceModelsClientService
.Setup(service => service.GetDeviceModel(It.IsAny<string>()))
.ReturnsAsync(new LoRaDeviceModelDto());

_ = this.mockLoRaWanDeviceClientService.Setup(service => service.GetGatewayIdList())
.ReturnsAsync(new LoRaGatewayIDList());

var cut = RenderComponent<EditDevice>(parameters => parameters.Add(p => p.context, CreateEditMode.Create));

// Act
await cut.Instance.ChangeModel(mockDeviceModel);
cut.WaitForElement("div.mud-tooltip-root:nth-child(2) > div.mud-tab").Click();

// Assert
cut.WaitForAssertion(() => cut.Find("div.mud-tooltip-root:nth-child(2) > div.mud-tab").TextContent.Should().Be("LoRaWAN"));
}
}
}

0 comments on commit 5b4a4cb

Please sign in to comment.