diff --git a/LynxAstro.DewController.Switch.UnitTests/SwitchUnitTests.cs b/LynxAstro.DewController.Switch.UnitTests/SwitchUnitTests.cs index d3aa19a..12f4d80 100644 --- a/LynxAstro.DewController.Switch.UnitTests/SwitchUnitTests.cs +++ b/LynxAstro.DewController.Switch.UnitTests/SwitchUnitTests.cs @@ -1,4 +1,5 @@ -using ASCOM.LynxAstro.DewController; +using System.Collections.Generic; +using ASCOM.LynxAstro.DewController; using Moq; using NUnit.Framework; @@ -10,12 +11,22 @@ namespace LynxAstro.DewController.Switch.UnitTests private ASCOM.LynxAstro.DewController.Switch _switch; private Mock _sharedResourcesWrapperMock; + private ProfileProperties _profileProperties; + [SetUp] public void Setup() { - _sharedResourcesWrapperMock = new Mock(); + _profileProperties = new ProfileProperties() + { + ComPort = "TestCom1", + SwitchNames = new List(), + TraceLogger = false + }; - _switch = new ASCOM.LynxAstro.DewController.Switch(); + _sharedResourcesWrapperMock = new Mock(); + _sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties); + + _switch = new ASCOM.LynxAstro.DewController.Switch(_sharedResourcesWrapperMock.Object); } [Test] diff --git a/LynxAstro.DewController.UnitTests/SharedResourcesUnitTests.cs b/LynxAstro.DewController.UnitTests/SharedResourcesUnitTests.cs index f0ff61c..db1d8ea 100644 --- a/LynxAstro.DewController.UnitTests/SharedResourcesUnitTests.cs +++ b/LynxAstro.DewController.UnitTests/SharedResourcesUnitTests.cs @@ -1,5 +1,4 @@ using System; -using System.Security.Cryptography.X509Certificates; using ASCOM.LynxAstro.DewController; using ASCOM.Utilities.Interfaces; using Moq; @@ -99,7 +98,7 @@ namespace LynxAstro.DewController.UnitTests [Test] public void WriteProfile_WhenCalled_WritesExpectedProfileSettings() { - string DriverId = "ASCOM.MeadeGeneric.Telescope"; + string DriverId = "ASCOM.LynxAstro.DewController.Switch"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -119,7 +118,7 @@ namespace LynxAstro.DewController.UnitTests SharedResources.WriteProfile(profileProperties); - Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope")); + Assert.That(profeWrapper.DeviceType, Is.EqualTo("Switch")); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Trace Level", profileProperties.TraceLogger.ToString()), Times.Once); profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once); } @@ -127,7 +126,7 @@ namespace LynxAstro.DewController.UnitTests [Test] public void ReadProfile_WhenCalled_ReturnsExpectedDefaultValues() { - string DriverId = "ASCOM.MeadeGeneric.Telescope"; + string DriverId = "ASCOM.LynxAstro.DewController.Switch"; string ComPortDefault = "COM1"; string TraceStateDefault = "false"; @@ -140,25 +139,14 @@ namespace LynxAstro.DewController.UnitTests Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); + profileWrapperMock.Setup(x => x.DeviceType).Returns("Switch"); + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault)) .Returns(() => TraceStateDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault)) .Returns(ComPortDefault); - profileWrapperMock - .Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, - GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault); - profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) - .Returns(PrecisionDefault); - profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault)) - .Returns(GuidingStyleDefault); - profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault)) - .Returns(BacklashCompensationDefault); - profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, ReverseFocuserDiectionDefault)) - .Returns(() => ReverseFocuserDiectionDefault); - + profileWrapperMock.Setup(x => x.GetValue(DriverId, It.IsRegex("^SwitchName_[0-9{1}]$"), string.Empty, It.IsAny())) .Returns((string driverId, string name, string subKey, string defaultValue) => defaultValue); @@ -172,7 +160,7 @@ namespace LynxAstro.DewController.UnitTests var profileProperties = SharedResources.ReadProfile(); - Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope")); + Assert.That(profeWrapper.DeviceType, Is.EqualTo("Switch")); Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault)); Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault))); } diff --git a/LynxAstro.DewController/SharedResources.cs b/LynxAstro.DewController/SharedResources.cs index 428898f..a94085f 100644 --- a/LynxAstro.DewController/SharedResources.cs +++ b/LynxAstro.DewController/SharedResources.cs @@ -132,7 +132,7 @@ namespace ASCOM.LynxAstro.DewController #region Profile - private const string DriverId = "ASCOM.MeadeGeneric.Telescope"; + private const string DriverId = "ASCOM.LynxAstro.DewController.Switch"; // Constants used for Profile persistence private const string ComPortProfileName = "COM Port"; @@ -145,7 +145,7 @@ namespace ASCOM.LynxAstro.DewController { using (IProfileWrapper driverProfile = ProfileFactory.Create()) { - driverProfile.DeviceType = "Telescope"; + driverProfile.DeviceType = "Switch"; driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString()); driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort); } @@ -164,7 +164,7 @@ namespace ASCOM.LynxAstro.DewController ProfileProperties profileProperties = new ProfileProperties(); using (IProfileWrapper driverProfile = ProfileFactory.Create()) { - driverProfile.DeviceType = "Telescope"; + driverProfile.DeviceType = "Switch"; profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault); profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault)); @@ -181,6 +181,7 @@ namespace ASCOM.LynxAstro.DewController if (!finished) profileProperties.SwitchNames.Add(switchValue); + switchNo++; } while (!finished); } diff --git a/build.build b/build.build new file mode 100644 index 0000000..05f3354 --- /dev/null +++ b/build.build @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file