Upgraded the Profile code to be contained inside a wrapper and started adding unit tests to cover.

This commit is contained in:
2019-10-21 21:16:09 +01:00
parent 438ec779b4
commit a155e27eac
7 changed files with 251 additions and 5 deletions
+11 -3
View File
@@ -18,6 +18,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using ASCOM.Meade.net.Wrapper;
using ASCOM.Utilities;
using ASCOM.Utilities.Interfaces;
@@ -68,6 +69,12 @@ namespace ASCOM.Meade.net
set => _sSharedSerial = value;
}
public static IProfileFactory ProfileFactory
{
get => _profileFactory ?? ( _profileFactory = new ProfileFactory());
set => _profileFactory = value;
}
public static void SendBlind(string message)
{
lock (LockObject)
@@ -132,12 +139,12 @@ namespace ASCOM.Meade.net
private const string TraceStateProfileName = "Trace Level";
private const string GuideRateProfileName = "Guide Rate Arc Seconds Per Second";
private const string PrecisionProfileName = "Precision";
public static void WriteProfile(ProfileProperties profileProperties)
{
lock (LockObject)
{
using (Profile driverProfile = new Profile())
using (IProfileWrapper driverProfile = ProfileFactory.Create())
{
driverProfile.DeviceType = "Telescope";
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
@@ -158,7 +165,7 @@ namespace ASCOM.Meade.net
lock (LockObject)
{
ProfileProperties profileProperties = new ProfileProperties();
using (Profile driverProfile = new Profile())
using (IProfileWrapper driverProfile = ProfileFactory.Create())
{
driverProfile.DeviceType = "Telescope";
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
@@ -222,6 +229,7 @@ namespace ASCOM.Meade.net
private static readonly Dictionary<string, DeviceHardware> ConnectedDevices = new Dictionary<string, DeviceHardware>();
private static readonly Dictionary<string, DeviceHardware> ConnectedDeviceIds = new Dictionary<string, DeviceHardware>();
private static IProfileFactory _profileFactory ;
/// <summary>