Skip to content

Commit

Permalink
Related to #1803 - Add unit test to module button to chek whether the…
Browse files Browse the repository at this point in the history
…s should be enabled or disabled (#1810)
  • Loading branch information
kbeaugrand authored Feb 27, 2023
1 parent 69d9e4f commit 40b230d
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,24 @@ public void ClickOnDeleteShouldDisplayConfirmationDialogAndRedirectIfConfirmed()
cut.WaitForAssertion(() => MockRepository.VerifyAll());
}

private IoTEdgeDevice SetupOnInitialisation()
[TestCase(false)]
[TestCase(true)]
public void WhenModulesArePresentCommandAreEnabledIfConnected(bool enabled)
{
// Arrange
_ = SetupOnInitialisation(enabled);

// Act
var cut = RenderComponent<EdgeDeviceDetailPage>(ComponentParameter.CreateParameter("deviceId", this.mockdeviceId));
cut.WaitForAssertion(() => cut.Find("#commandTest"));

var commandButton = cut.Find("#commandTest");

// Assert
Assert.AreEqual(enabled, !commandButton.HasAttribute("disabled"));
}

private IoTEdgeDevice SetupOnInitialisation(bool connected = true)
{
var tags = new Dictionary<string, string>()
{
Expand All @@ -553,7 +570,7 @@ private IoTEdgeDevice SetupOnInitialisation()
{
DeviceId = this.mockdeviceId,
DeviceName = "test",
ConnectionState = "Connected",
ConnectionState = connected ? "Connected" : "Disconnected",
ModelId = Guid.NewGuid().ToString(),
Tags = tags,
Modules = new List<IoTEdgeModule>()
Expand Down

0 comments on commit 40b230d

Please sign in to comment.