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.
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using System;
|
|
using Crestron.SimplSharp;
|
|
using PdCore = PepperDash.Core.Abstractions;
|
|
|
|
namespace PepperDash.Core.Adapters;
|
|
|
|
/// <summary>
|
|
/// Production adapter — delegates ICrestronConsole calls to the real Crestron SDK.
|
|
/// </summary>
|
|
public sealed class CrestronConsoleAdapter : PdCore.ICrestronConsole
|
|
{
|
|
public void PrintLine(string message) => CrestronConsole.PrintLine(message);
|
|
|
|
public void Print(string message) => CrestronConsole.Print(message);
|
|
|
|
public void ConsoleCommandResponse(string message) =>
|
|
CrestronConsole.ConsoleCommandResponse(message);
|
|
|
|
public void AddNewConsoleCommand(
|
|
Action<string> callback,
|
|
string command,
|
|
string helpText,
|
|
PdCore.ConsoleAccessLevel accessLevel)
|
|
{
|
|
var crestronLevel = accessLevel switch
|
|
{
|
|
PdCore.ConsoleAccessLevel.AccessAdministrator => ConsoleAccessLevelEnum.AccessAdministrator,
|
|
PdCore.ConsoleAccessLevel.AccessProgrammer => ConsoleAccessLevelEnum.AccessProgrammer,
|
|
_ => ConsoleAccessLevelEnum.AccessOperator,
|
|
};
|
|
|
|
// Wrap Action<string> in a lambda — Crestron's delegate is not a standard Action<string>.
|
|
CrestronConsole.AddNewConsoleCommand(s => callback(s), command, helpText, crestronLevel);
|
|
}
|
|
}
|