mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 19:08:29 +00:00
- Introduced `FakeCrestronEnvironment` and `FakeEthernetHelper` for testing purposes. - Implemented `InMemoryCrestronDataStore` to facilitate unit tests for data storage. - Created `DebugServiceTests` to validate the behavior of debug-related services. - Added project files for unit tests targeting .NET 9.0 with necessary dependencies. - Developed production adapters (`CrestronConsoleAdapter`, `CrestronDataStoreAdapter`, `CrestronEnvironmentAdapter`, `CrestronEthernetAdapter`) to interface with the Crestron SDK. - Updated `Debug` class to utilize injected service abstractions instead of direct SDK calls. - Enhanced `ControlSystem` initialization to register service adapters before usage.
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using PepperDash.Core.Abstractions;
|
|
|
|
namespace PepperDash.Core.Tests.Fakes;
|
|
|
|
/// <summary>
|
|
/// No-op ICrestronConsole that captures output for test assertions.
|
|
/// </summary>
|
|
public class CapturingCrestronConsole : ICrestronConsole
|
|
{
|
|
public List<string> Lines { get; } = new();
|
|
public List<string> CommandResponses { get; } = new();
|
|
public List<(string Command, string HelpText)> RegisteredCommands { get; } = new();
|
|
|
|
public void PrintLine(string message) => Lines.Add(message);
|
|
public void Print(string message) => Lines.Add(message);
|
|
public void ConsoleCommandResponse(string message) => CommandResponses.Add(message);
|
|
|
|
public void AddNewConsoleCommand(
|
|
Action<string> callback,
|
|
string command,
|
|
string helpText,
|
|
ConsoleAccessLevel accessLevel)
|
|
{
|
|
RegisteredCommands.Add((command, helpText));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Minimal no-op ICrestronConsole that discards all output. Useful when you only
|
|
/// care about the system under test and not what it logs.
|
|
/// </summary>
|
|
public class NoOpCrestronConsole : ICrestronConsole
|
|
{
|
|
public void PrintLine(string message) { }
|
|
public void Print(string message) { }
|
|
public void ConsoleCommandResponse(string message) { }
|
|
public void AddNewConsoleCommand(Action<string> _, string __, string ___, ConsoleAccessLevel ____) { }
|
|
}
|