From 036a9d711648279ef43b0bf354c1bb9783c719d3 Mon Sep 17 00:00:00 2001 From: Sebastian Godelet Date: Sun, 13 Jun 2021 09:45:07 +1000 Subject: [PATCH] Add multi-connection test for TargetRightAscension --- .../TelescopeUnitTests.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 9a3adf3..4467bf8 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -2516,6 +2516,44 @@ namespace Meade.net.Telescope.UnitTests Assert.That(result, Is.EqualTo(rightAscension)); } + [TestCase(0d)] + [TestCase(6d)] + [TestCase(12d)] + [TestCase(23.599d)] + public void TargetRightAscension_Set_WhenSecondConnectionMade_ThenSlewSettleTimeIsPreserved(double targetRightAscension) + { + var targetRightAscensionHMS = targetRightAscension + "HMS"; + var command = $"Sr{targetRightAscensionHMS}"; + + _utilMock.Setup(x => x.HoursToHMS(targetRightAscension, ":", ":", ":", 2)).Returns(targetRightAscensionHMS); + _utilMock.Setup(x => x.HMSToHours(targetRightAscensionHMS)).Returns(targetRightAscension); + _sharedResourcesWrapperMock.Setup(x => x.SendChar(command, false)).Returns("1"); + + ConnectTelescope(); + Assert.That(_connectionInfo.SameDevice, Is.EqualTo(1)); + Assert.That(_sharedResourcesWrapperMock.Object.IsLongFormat, Is.True); + + _telescope.TargetRightAscension = targetRightAscension; + + Assert.That(_telescope.TargetRightAscension, Is.EqualTo(targetRightAscension)); + + var secondTelescopeInstance = + new ASCOM.Meade.net.Telescope(_utilMock.Object, _utilExtraMock.Object, _astroUtilsMock.Object, + _sharedResourcesWrapperMock.Object, _astroMathsMock.Object, _clockMock.Object, _novasMock.Object); + + Assert.That(secondTelescopeInstance.Connected, Is.False); + + _connectionInfo.SameDevice = 2; + secondTelescopeInstance.Connected = true; + + Assert.That(_sharedResourcesWrapperMock.Object.IsLongFormat, Is.True); + Assert.That(secondTelescopeInstance.TargetRightAscension, Is.EqualTo(targetRightAscension)); + + _utilMock.Verify(x => x.HoursToHMS(targetRightAscension, ":", ":", ":", 2), Times.Once); + _utilMock.Verify(x => x.HMSToHours(targetRightAscensionHMS), Times.Once); + _sharedResourcesWrapperMock.Verify(x => x.SendChar(command, false), Times.Once); + } + [Test] public void Tracking_Get_WhenDefault_ThenIsTrue() {