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.
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using Crestron.SimplSharp.CrestronDataStore;
|
|
using PepperDash.Core.Abstractions;
|
|
|
|
namespace PepperDash.Core.Adapters;
|
|
|
|
/// <summary>
|
|
/// Production adapter — delegates ICrestronDataStore calls to the real Crestron SDK.
|
|
/// </summary>
|
|
public sealed class CrestronDataStoreAdapter : ICrestronDataStore
|
|
{
|
|
public void InitStore() => CrestronDataStoreStatic.InitCrestronDataStore();
|
|
|
|
public bool TryGetLocalInt(string key, out int value)
|
|
{
|
|
var err = CrestronDataStoreStatic.GetLocalIntValue(key, out value);
|
|
return err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS;
|
|
}
|
|
|
|
public bool SetLocalInt(string key, int value)
|
|
{
|
|
var err = CrestronDataStoreStatic.SetLocalIntValue(key, value);
|
|
return err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS;
|
|
}
|
|
|
|
public bool SetLocalUint(string key, uint value)
|
|
{
|
|
var err = CrestronDataStoreStatic.SetLocalUintValue(key, value);
|
|
return err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS;
|
|
}
|
|
|
|
public bool TryGetLocalBool(string key, out bool value)
|
|
{
|
|
var err = CrestronDataStoreStatic.GetLocalBoolValue(key, out value);
|
|
return err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS;
|
|
}
|
|
|
|
public bool SetLocalBool(string key, bool value)
|
|
{
|
|
var err = CrestronDataStoreStatic.SetLocalBoolValue(key, value);
|
|
return err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS;
|
|
}
|
|
}
|