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.
39 lines
1.8 KiB
C#
39 lines
1.8 KiB
C#
using System;
|
|
using Crestron.SimplSharp;
|
|
using PepperDash.Core.Abstractions;
|
|
|
|
namespace PepperDash.Core.Adapters;
|
|
|
|
/// <summary>
|
|
/// Production adapter — delegates IEthernetHelper calls to the real Crestron SDK.
|
|
/// </summary>
|
|
public sealed class CrestronEthernetAdapter : IEthernetHelper
|
|
{
|
|
public string GetEthernetParameter(EthernetParameterType parameter, short ethernetAdapterId)
|
|
{
|
|
var crestronParam = parameter switch
|
|
{
|
|
EthernetParameterType.GetCurrentIpAddress =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
|
|
EthernetParameterType.GetHostname =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME,
|
|
EthernetParameterType.GetDomainName =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME,
|
|
EthernetParameterType.GetLinkStatus =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_LINK_STATUS,
|
|
EthernetParameterType.GetCurrentDhcpState =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE,
|
|
EthernetParameterType.GetCurrentIpMask =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK,
|
|
EthernetParameterType.GetCurrentRouter =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER,
|
|
EthernetParameterType.GetMacAddress =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS,
|
|
EthernetParameterType.GetDnsServer =>
|
|
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(parameter), parameter, null),
|
|
};
|
|
|
|
return CrestronEthernetHelper.GetEthernetParameter(crestronParam, ethernetAdapterId);
|
|
}
|
|
}
|