From ea07c7b625bc95cfbad1b22f204298a558d9ee37 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Mon, 17 Feb 2025 15:56:34 +0000 Subject: [PATCH] Fixed unit tests --- .../SharedResourcesUnitTests.cs | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index 8ca906c..740f652 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -151,21 +151,21 @@ namespace Meade.net.UnitTests string TraceStateDefault = "false"; string ComPortDefault = "COM1"; - string SpeedDefault = "9600"; - string DataBitsDefault = "8"; + int SpeedDefault = 9600; + int DataBitsDefault = 8; string StopBitsDefault = "One"; string HandshakeDefault = "None"; string ParityDefault = "None"; - string RtsDtrEnabledDefault = "true"; + bool RtsDtrEnabledDefault = true; - string GuideRateProfileNameDefault = "10.077939"; //67% of sidereal rate + double GuideRateProfileNameDefault = 10.077939; //67% of sidereal rate string PrecisionDefault = "Unchanged"; string GuidingStyleDefault = "Auto"; - string BacklashCompensationDefault = "3000"; - string ReverseFocuserDiectionDefault = "true"; + int BacklashCompensationDefault = 3000; + bool ReverseFocuserDiectionDefault = true; - string SendDateTimeDefault = "true"; + bool SendDateTimeDefault = true; string SkipPromptsDefault = "true"; string ParkedBehaviourDefault = "No Coordinates"; @@ -184,23 +184,23 @@ namespace Meade.net.UnitTests 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); + .Setup(x => x.GetValueDouble(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty, + GuideRateProfileNameDefault.ToString())).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)) + x.GetValueInt(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault.ToString())) .Returns(BacklashCompensationDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, "true")) + x.GetValueBool(DriverId, "Reverse Focuser Direction", string.Empty, "true")) .Returns(() => ReverseFocuserDiectionDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + x.GetValueInt(DriverId, "Speed", string.Empty, SpeedDefault.ToString())) .Returns(() => SpeedDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) + x.GetValueInt(DriverId, "Data Bits", string.Empty, DataBitsDefault.ToString())) .Returns(() => DataBitsDefault); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Stop Bits", string.Empty, StopBitsDefault)) @@ -212,7 +212,7 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Parity", string.Empty, ParityDefault)) .Returns(() => ParityDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Rts / Dtr", string.Empty, "false")) + x.GetValueBool(DriverId, "Rts / Dtr", string.Empty, "false")) .Returns(() => RtsDtrEnabledDefault); profileWrapperMock.Setup(x => @@ -239,7 +239,7 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false")) + x.GetValueBool(DriverId, "Send Date and time on connect", string.Empty, "false")) .Returns(() => SendDateTimeDefault); profileWrapperMock.Setup(x => @@ -264,21 +264,21 @@ namespace Meade.net.UnitTests Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault)); Assert.That(profileProperties.GuideRateArcSecondsPerSecond, - Is.EqualTo(double.Parse(GuideRateProfileNameDefault))); + Is.EqualTo(GuideRateProfileNameDefault)); Assert.That(profileProperties.Precision, Is.EqualTo(PrecisionDefault)); Assert.That(profileProperties.GuidingStyle, Is.EqualTo(GuidingStyleDefault)); - Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(int.Parse(BacklashCompensationDefault))); - Assert.That(profileProperties.ReverseFocusDirection, Is.EqualTo(bool.Parse(ReverseFocuserDiectionDefault))); + Assert.That(profileProperties.BacklashCompensation, Is.EqualTo(BacklashCompensationDefault)); + Assert.That(profileProperties.ReverseFocusDirection, Is.EqualTo(ReverseFocuserDiectionDefault)); - Assert.That(profileProperties.Speed, Is.EqualTo(int.Parse(SpeedDefault))); - Assert.That(profileProperties.DataBits, Is.EqualTo(int.Parse(DataBitsDefault))); + Assert.That(profileProperties.Speed, Is.EqualTo(SpeedDefault)); + Assert.That(profileProperties.DataBits, Is.EqualTo(DataBitsDefault)); Assert.That(profileProperties.StopBits, Is.EqualTo(StopBitsDefault)); Assert.That(profileProperties.Handshake, Is.EqualTo(HandshakeDefault)); Assert.That(profileProperties.Parity, Is.EqualTo(ParityDefault)); - Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(bool.Parse(RtsDtrEnabledDefault))); + Assert.That(profileProperties.RtsDtrEnabled, Is.EqualTo(RtsDtrEnabledDefault)); - Assert.That(profileProperties.SendDateTime, Is.EqualTo(bool.Parse(SendDateTimeDefault))); + Assert.That(profileProperties.SendDateTime, Is.EqualTo(SendDateTimeDefault)); } [TestCase("TCP")] @@ -692,15 +692,15 @@ namespace Meade.net.UnitTests } } - [TestCase("57600")] - [TestCase("38400")] - [TestCase("28800")] - [TestCase("19200")] - [TestCase("14400")] - [TestCase("4800")] - [TestCase("2400")] - [TestCase("1200")] - public void Connect_WhenSpeedIsFastAndAutostarAtDefault_ThenConnectsAutoStarSpeedChanged(string WantedSpeed) + [TestCase(57600)] + [TestCase(38400)] + [TestCase(28800)] + [TestCase(19200)] + [TestCase(14400)] + [TestCase(4800)] + [TestCase(2400)] + [TestCase(1200)] + public void Connect_WhenSpeedIsFastAndAutostarAtDefault_ThenConnectsAutoStarSpeedChanged(int WantedSpeed) { string deviceId = "Serial"; @@ -739,7 +739,7 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + x.GetValueInt(DriverId, "Speed", string.Empty, SpeedDefault)) .Returns(() => WantedSpeed); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault)) @@ -812,15 +812,15 @@ namespace Meade.net.UnitTests } } - [TestCase("57600")] - [TestCase("38400")] - [TestCase("28800")] - [TestCase("19200")] - [TestCase("14400")] - [TestCase("4800")] - [TestCase("2400")] - [TestCase("1200")] - public void Connect_WhenAutostarReportsFailedToChangeSpeec_ThenConnectsAutoStarAtDefaultSpeed(string WantedSpeed) + [TestCase(57600)] + [TestCase(38400)] + [TestCase(28800)] + [TestCase(19200)] + [TestCase(14400)] + [TestCase(4800)] + [TestCase(2400)] + [TestCase(1200)] + public void Connect_WhenAutostarReportsFailedToChangeSpeec_ThenConnectsAutoStarAtDefaultSpeed(int WantedSpeed) { string deviceId = "Serial"; @@ -859,7 +859,7 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault)) .Returns(PrecisionDefault); profileWrapperMock.Setup(x => - x.GetValue(DriverId, "Speed", string.Empty, SpeedDefault)) + x.GetValueInt(DriverId, "Speed", string.Empty, SpeedDefault)) .Returns(() => WantedSpeed); profileWrapperMock.Setup(x => x.GetValue(DriverId, "Data Bits", string.Empty, DataBitsDefault))