Added check to ensure that telescope is in Polar Mode when attempting to PulseGuide. CanPulseGuide also fails when scope is in AltAz mode.
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Meade.net.Telescope.UnitTests
|
||||
{
|
||||
public class TestProperties
|
||||
{
|
||||
public string AlignmentMode { get; internal set; } = "P";
|
||||
internal string telescopeRaResult { get; set; } = "HH:MM:SS";
|
||||
internal double rightAscension { get; set; } = 1.2; //todo rename to declination;
|
||||
internal double declination { get; set; } = 45;
|
||||
@@ -155,6 +156,9 @@ namespace Meade.net.Telescope.UnitTests
|
||||
_parkedPosition = parkedPostion;
|
||||
});
|
||||
|
||||
const char ack = (char)6;
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar(ack.ToString(), false)).Returns( () => _testProperties.AlignmentMode);
|
||||
|
||||
_sharedResourcesWrapperMock.SetupGet(x => x.IsParked).Returns(() => _isParked);
|
||||
_sharedResourcesWrapperMock.SetupGet(x => x.ParkedPosition).Returns(() => _parkedPosition);
|
||||
|
||||
@@ -793,9 +797,7 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[TestCase("G", AlignmentModes.algGermanPolar, TelescopeList.Autostar497, TelescopeList.Autostar497_43Eg)]
|
||||
public void AlignmentMode_Get_WhenScopeInAltAz_ReturnsAltAz(string telescopeMode, AlignmentModes alignmentMode, string productName, string firmware)
|
||||
{
|
||||
const char ack = (char)6;
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendChar(ack.ToString(), false)).Returns(telescopeMode);
|
||||
|
||||
_testProperties.AlignmentMode = telescopeMode;
|
||||
ConnectTelescope(productName, firmware, $"{telescopeMode}N0");
|
||||
|
||||
var actualResult = _telescope.AlignmentMode;
|
||||
@@ -806,6 +808,7 @@ namespace Meade.net.Telescope.UnitTests
|
||||
[Test]
|
||||
public void AlignmentMode_Get_WhenUnknownAlignmentMode_ThrowsException()
|
||||
{
|
||||
_testProperties.AlignmentMode = "";
|
||||
ConnectTelescope();
|
||||
|
||||
Assert.Throws<InvalidValueException>(() =>
|
||||
@@ -929,13 +932,25 @@ namespace Meade.net.Telescope.UnitTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanPulseGuide_Get_ReturnsTrue()
|
||||
public void CanPulseGuide_GetInPolarMode_ReturnsTrue()
|
||||
{
|
||||
_testProperties.AlignmentMode = "P";
|
||||
ConnectTelescope();
|
||||
var result = _telescope.CanPulseGuide;
|
||||
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanPulseGuide_GetInAltAzMode_ReturnsFalse()
|
||||
{
|
||||
_testProperties.AlignmentMode = "A";
|
||||
ConnectTelescope();
|
||||
var result = _telescope.CanPulseGuide;
|
||||
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSetDeclinationRate_Get_ReturnsFalse()
|
||||
{
|
||||
@@ -1696,6 +1711,23 @@ namespace Meade.net.Telescope.UnitTests
|
||||
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide whilst slewing to target."));
|
||||
}
|
||||
|
||||
[TestCase(GuideDirections.guideEast)]
|
||||
[TestCase(GuideDirections.guideWest)]
|
||||
[TestCase(GuideDirections.guideNorth)]
|
||||
[TestCase(GuideDirections.guideSouth)]
|
||||
public void PulseGuide_WhenAltAzPulseGuideAttempted_ThenThrowsExpectedException(GuideDirections direction)
|
||||
{
|
||||
_testProperties.AlignmentMode = "A";
|
||||
_sharedResourcesWrapperMock.Setup(x => x.SendString("D", false)).Returns("");
|
||||
|
||||
var duration = 1;
|
||||
ConnectTelescope();
|
||||
|
||||
var exception = Assert.Throws<InvalidOperationException>(() => _telescope.PulseGuide(direction, duration));
|
||||
|
||||
Assert.That(exception.Message, Is.EqualTo("Unable to PulseGuide whilst in AltAz mode."));
|
||||
}
|
||||
|
||||
[TestCase(GuideDirections.guideEast, TelescopeAxes.axisPrimary)]
|
||||
[TestCase(GuideDirections.guideWest, TelescopeAxes.axisPrimary)]
|
||||
[TestCase(GuideDirections.guideNorth, TelescopeAxes.axisSecondary)]
|
||||
|
||||
@@ -1274,8 +1274,10 @@ namespace ASCOM.Meade.net
|
||||
{
|
||||
get
|
||||
{
|
||||
LogMessage("CanPulseGuide", "Get - " + true);
|
||||
return true;
|
||||
CheckConnected("CanPulseGuide");
|
||||
var canPulseGuide = AlignmentMode != AlignmentModes.algAltAz;
|
||||
LogMessage("CanPulseGuide", $"Get - {canPulseGuide}");
|
||||
return canPulseGuide;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1759,6 +1761,9 @@ namespace ASCOM.Meade.net
|
||||
if (IsSlewingToTarget())
|
||||
throw new InvalidOperationException("Unable to PulseGuide whilst slewing to target.");
|
||||
|
||||
if (AlignmentMode == AlignmentModes.algAltAz)
|
||||
throw new InvalidOperationException("Unable to PulseGuide whilst in AltAz mode.");
|
||||
|
||||
SharedResourcesWrapper.IsGuiding = true;
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user