From 64b949551e38c8819f036017a85366e054e9f25b Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 13 Jul 2019 16:27:47 +0100 Subject: [PATCH] More unit testing, this time for pulse guiding support --- .../TelescopeUnitTests.cs | 16 ++++++++++++++-- Meade.net.Telescope/Telescope.cs | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 2749b4d..e0af2bf 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -35,8 +35,8 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock = new Mock(); _sharedResourcesWrapperMock.Setup(x => x.SendString(":GZ#")).Returns("DDD*MM’SS#"); - _sharedResourcesWrapperMock.Setup(x => x.AUTOSTAR497).Returns(() => "AUTOSTAR497"); - _sharedResourcesWrapperMock.Setup(x => x.AUTOSTAR497_31EE).Returns(() => "31EE"); + _sharedResourcesWrapperMock.Setup(x => x.AUTOSTAR497).Returns(() => "AUTOSTAR"); + _sharedResourcesWrapperMock.Setup(x => x.AUTOSTAR497_31EE).Returns(() => "31Ee"); _sharedResourcesWrapperMock.Setup(x => x.Lock(It.IsAny())).Callback(action => { action(); }); @@ -296,6 +296,18 @@ namespace Meade.net.Telescope.UnitTests _sharedResourcesWrapperMock.Verify(x => x.Disconnect(It.IsAny()), Times.Once()); } + [TestCase("AUTOSTAR", "30Ab", false)] + [TestCase("AUTOSTAR","31Ee", true)] + [TestCase("AUTOSTAR", "41Aa", true)] + [TestCase("AUTOSTAR II", "", false)] + public void IsNewPulseGuidingSupported_ThenIsSupported_ThenReturnsTrue(string productName, string firmware, bool isSupported) + { + _sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(productName); + _sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(firmware); + var result = _telescope.IsNewPulseGuidingSupported(); + + Assert.That(result, Is.EqualTo(isSupported)); + } } } diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 42dfabb..d04c107 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -350,7 +350,7 @@ namespace ASCOM.Meade.net return (comparison >= 0); } - private void SetLongFormat(bool setLongFormat) + public void SetLongFormat(bool setLongFormat) { _sharedResourcesWrapper.Lock(() => {