Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Implementation Plan: Simulated Broadlink Device for E2E Testing

Based on the specification in _spec_SimulatedBroadlinkDevice.md, I implemented a simulated Broadlink device following the existing SimulatedTiVo pattern.

Implementation Checklist

  • Understand the specification and existing codebase
  • Create core Broadlink simulator infrastructure
  • Implement Broadlink protocol handling
  • Update test environment
  • Create test steps and feature
  • Fix build errors and warnings
  • Add discovery configuration
  • Run and validate tests (all 3 tests pass)
  • Update documentation
  • Address code review feedback
    • Moved logic from BroadlinkSteps to ISimulatedBroadlinkDeviceExtensions in TestServices
    • Removed RegisterDevice, StartDevice, TryGetDevice methods from ISimulatedEnvironment
    • Refactored SimulatedEnvironment to use constructor injection with ILoggerFactory
    • Renamed ISimulatedDevice to ISimulatedTiVoDevice
    • Removed BoundPort property (using Port from base interface)
    • Updated builders to accept ILoggerFactory for Reqnroll DI compatibility
    • Removed WithPort customization (always use ephemeral ports)
    • Updated documentation to link to code files instead of embedding samples

Final Status

All requirements met:

  • Simulated Broadlink device fully functional with complete protocol support
  • All 3 E2E tests pass (startup/shutdown, TiVo command, Broadlink command)
  • Build succeeds with zero warnings (/warnaserror)
  • Code review feedback fully addressed
  • Architecture improved for better testability and DI support
  • Documentation updated to stay current with code
Original prompt

This section details on the original issue you should resolve

<issue_title>Create a simulated Broadlink device for E2E tests</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
End to end tests start the host application with a NullCommandService for Broadlink commands, which means none of the Broadlink support is being tested.

Describe the solution you'd like
Create a simulated Broadlink device, similar to the SimulatedTiVoDevice, which the application can connect to in test scenarios.

Additional context
Follow the specifications and implementation plan in _spec_SimulatedBroadlinkDevice.md (added in PR #74)</issue_description>

<agent_instructions>Implement this feature as described in _spec_SimulatedBroadlinkDevice.md. When complete, the tests should not use --broadlink:Fake, there should be a new test for a Broadlink command, the build should pass without warnings or errors (build with /warnaserror), and all tests should pass, especially the headless E2E tests. When finished, replace _spec_SimulatedBroadlinkDevice.md and _doc_SimulatedTiVoDevice.md with a combined _doc_SimulatedDevices.md that describes the system as implemented.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits January 29, 2026 18:01
Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
…improve documentation

Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Copilot AI changed the title [WIP] Create simulated Broadlink device for E2E tests Add simulated Broadlink device for E2E testing Jan 29, 2026
Copilot AI requested a review from jodavis January 29, 2026 18:29
@github-actions
Copy link

github-actions bot commented Jan 29, 2026

Test Results

311 tests  +3   305 ✅ +1   1m 8s ⏱️ -44s
  5 suites ±0     6 💤 +2 
  5 files   ±0     0 ❌ ±0 

Results for commit 0146614. ± Comparison against base commit 6854c1d.

This pull request removes 3 and adds 5 tests. Note that renamed tests count towards both.
,False)
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesKeyNameAsync (Hello
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesValueAsync (Invalid
AdaptiveRemote.EndToEndTests.ConsoleHost.Features.BroadlinkDeviceIntegrationFeature ‑ Broadlink receives Power command
AdaptiveRemote.EndToEndTests.HeadlessHost.Features.BroadlinkDeviceIntegrationFeature ‑ Broadlink receives Power command
AdaptiveRemote.EndToEndTests.WpfHost.Features.BroadlinkDeviceIntegrationFeature ‑ Broadlink receives Power command
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesKeyNameAsync (Hello
,False)
AdaptiveRemote.Services.ProgrammaticSettings.PersistSettingsTests ‑ PersistSettings_Set_ValidatesValueAsync (Invalid
,False)

♻️ This comment has been updated with latest results.

Copy link
Owner

@jodavis jodavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Please make these changes.

[Then(@"I should see the Broadlink device recorded at least one inbound packet")]
public void ThenIShouldSeeTheBroadlinkDeviceRecordedAtLeastOneInboundPacket()
{
ISimulatedBroadlinkDevice? device = Environment.Broadlink;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally there would not be so much logic in the Step implementations themselves. The logic should be in the TestServices assembly, and the step definitions should be about translating and validating steps and parameters. That way if I need to build non-Gherkin tests, all the logic is available.

I'm not sure the best way to handle this. Either the logic could be build directly into the SimulatedBroadlinkDevice itself, or it could be build as extension methods on ISimulatedBroadlinkDevice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved logic to extension methods in ISimulatedBroadlinkDeviceExtensions.cs - HasRecordedInboundPacketWithIrData(), GetRecordedPacketsDebugString(), GetFirstPacketWithIrData(), and GetFirstMalformedPacket(). Step definitions now just call these methods. (7e3b34f)

@@ -7,10 +8,19 @@ namespace AdaptiveRemote.EndtoEndTests.Host;
/// </summary>
public sealed class SimulatedEnvironment : ISimulatedEnvironment
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this could be implemented like

Suggested change
public sealed class SimulatedEnvironment : ISimulatedEnvironment
public sealed class SimulatedEnvironment : ISimulatedEnvironment
{
public SimulatedEnvironment(SimulatedBroadlinkDeviceBuilder broadlinkBuilder, SimulatedTiVoDeviceBuilder tivoBuilder)
{
// Set the parameters into the properties here
}
}

Then all these objects can be created via Reqnroll's DI system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to accept ILoggerFactory in constructor. The environment now creates the builders internally and starts the devices. (7e3b34f)

/// <summary>
/// Gets the actual UDP port the device is bound to (useful when using ephemeral ports).
/// </summary>
int BoundPort { get; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to just Port

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, there is already a Port property because this extends ISimulatedDevice. I wonder what this is for..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed BoundPort property. Since ISimulatedBroadlinkDevice extends ISimulatedTiVoDevice (formerly ISimulatedDevice), it inherits the Port property which serves the same purpose. (7e3b34f)


### Core Interfaces

```csharp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of including all these code samples, just link to the actual code. That way the documentation won't get out of date.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the documentation should be adding information that's not easily understood from the code. Links to code files can be provided where seeing the code would help with understanding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the documentation to link to actual code files instead of embedding code samples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated documentation to link to actual code files instead of embedding samples. Removed all code blocks and replaced with links to implementation files. Added references to test steps, features, and protocol implementation. (0146614)

Copilot AI and others added 2 commits January 29, 2026 23:16
- Move test logic from BroadlinkSteps to extension methods in TestServices
- Remove registration methods from ISimulatedEnvironment (use constructor injection)
- Rename ISimulatedDevice to ISimulatedTiVoDevice for clarity
- Remove BoundPort property (use Port from base interface)
- Update builders to accept ILoggerFactory instead of ILogger
- Remove WithPort customization (always use ephemeral ports)
- Simplify SimulatedEnvironment to construct devices directly

Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Replace code samples with links to actual implementation files in _doc_SimulatedDevices.md

Co-authored-by: jodavis <6740581+jodavis@users.noreply.github.com>
Copilot AI requested a review from jodavis January 29, 2026 23:24
@jodavis jodavis marked this pull request as ready for review January 30, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a simulated Broadlink device for E2E tests

2 participants