diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index e483868..2a0403c 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -67,10 +67,10 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Object, _astroMathsMock.Object); } - private void ConnectTelescope() + private void ConnectTelescope(string productName = TelescopeList.Autostar497, string firmwareVersion = TelescopeList.Autostar497_31Ee) { - _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => TelescopeList.Autostar497); - _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => TelescopeList.Autostar497_31Ee); + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => productName); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => firmwareVersion); _telescope.Connected = true; } @@ -2184,6 +2184,25 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"),Times.Once); } + [TestCase(TelescopeList.LX200CLASSIC,"","|", true)] + [TestCase(TelescopeList.LX200CLASSIC, "", "||||||||", true)] + [TestCase(TelescopeList.LX200CLASSIC, "", "", false)] + [TestCase(TelescopeList.LX200CLASSIC, "", "[FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF][FF] [FF][FF][FF][FF][FF][FF]", false)] + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "|", true)] + [TestCase(TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg, "", false)] + public void Slewing_WhenTelescopeNotSlewing_ThenReturnsFalse(string productName, string firmwareVersion, string response, bool isSlewing) + { + _sharedResourcesWrapperMock.Setup(x => x.SendString(":D#")).Returns(response); + + ConnectTelescope(productName, firmwareVersion); + + var result = _telescope.Slewing; + + Assert.That(result, Is.EqualTo(isSlewing)); + + _sharedResourcesWrapperMock.Verify(x => x.SendString(":D#"), Times.Once); + } + [TestCase(1, TelescopeAxes.axisPrimary)] [TestCase(-1, TelescopeAxes.axisPrimary)] [TestCase(1, TelescopeAxes.axisSecondary)] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 08d21f0..c208cc9 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -1883,9 +1883,9 @@ namespace ASCOM.Meade.net } var trimmedResult = result.Trim(); - var isResultEmpty = trimmedResult != string.Empty; + var isResultEmpty = trimmedResult == string.Empty; - var isSlewing = isResultEmpty; + var isSlewing = !isResultEmpty; if (!isResultEmpty) //the LX-200 can return crap from the buffer when it's not slewing so let's try to filter that out. { diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index 61e4293..440c4bd 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -4,30 +4,30 @@ { #region Autostar 497/Audiostar - public static readonly string Autostar497 = "Autostar"; + public const string Autostar497 = "Autostar"; //Autostar/Audiostar firmware revisions // ReSharper disable once InconsistentNaming - public static readonly string Autostar497_30Ee = "30Ee"; + public const string Autostar497_30Ee = "30Ee"; // ReSharper disable once InconsistentNaming - public static readonly string Autostar497_31Ee = "31Ee"; + public const string Autostar497_31Ee = "31Ee"; // ReSharper disable once InconsistentNaming - public static readonly string Autostar497_43Eg = "43Eg"; + public const string Autostar497_43Eg = "43Eg"; #endregion #region LX200GPS // ReSharper disable once InconsistentNaming - public static readonly string LX200GPS = "LX2001"; + public const string LX200GPS = "LX2001"; // ReSharper disable once InconsistentNaming - public static readonly string LX200GPS_42G = "4.2G"; + public const string LX200GPS_42G = "4.2G"; #endregion #region LX200EMC // ReSharper disable once InconsistentNaming - public static readonly string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported! + public const string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported! #endregion } }