Compare commits

...

13 Commits

Author SHA1 Message Date
ColinD a6308f1a64 Added a missing . to the name file name. Working :) 2019-07-14 23:00:15 +01:00
ColinD 0475217d62 Trying to read the BUILD_NUMBER from the environment. 2019-07-14 22:56:32 +01:00
ColinD e89f01ed51 Another try 2019-07-14 22:40:45 +01:00
ColinD 2846e9f719 Anotther try. 2019-07-14 22:32:38 +01:00
ColinD a7904d7485 Another attempt at the version number rename. 2019-07-14 22:28:32 +01:00
ColinD 12c11b4987 Removed unneeded comments 2019-07-14 22:19:55 +01:00
ColinD 07569b146e Trying the nant variable inside the string. 2019-07-14 22:19:05 +01:00
ColinD 112fdf0bb9 Experiment on build.build to see if I can rename the msi file 2019-07-14 22:14:43 +01:00
ColinD 73e8e8ffe8 More unit testing 2019-07-14 22:05:25 +01:00
ColinD 34a145765b More unit testing
Fixed issue when setting site latitude to negative value.
2019-07-14 21:47:02 +01:00
ColinD e3f82ff232 More unit tests 2019-07-14 17:51:34 +01:00
ColinD 5f5d819f3b More unit tests added 2019-07-14 17:12:56 +01:00
ColinD 69434454ca More unit test coverage 2019-07-13 23:26:19 +01:00
3 changed files with 836 additions and 8 deletions
@@ -1,5 +1,5 @@
using System;
using System.Globalization;
using System.Diagnostics.Eventing.Reader;
using ASCOM;
using ASCOM.Astrometry.AstroUtils;
using ASCOM.DeviceInterface;
@@ -506,5 +506,822 @@ namespace Meade.net.Telescope.UnitTests
Assert.That(excpetion.Property, Is.EqualTo("AlignmentMode"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void ApertureArea_Get_ThrowsNotImplementedException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.ApertureArea; });
Assert.That(excpetion.Property, Is.EqualTo("ApertureArea"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void ApertureDiameter_Get_ThrowsNotImplementedException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.ApertureDiameter; });
Assert.That(excpetion.Property, Is.EqualTo("ApertureDiameter"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void AtHome_Get_ReturnsFalse()
{
var result = _telescope.AtHome;
Assert.That(result, Is.False);
}
[Test]
public void AtPark_Get_WhenNotParked_ThenReturnsFalse()
{
var result = _telescope.AtPark;
Assert.That(result, Is.False);
}
[Test]
public void AtPark_Get_WhenParked_ThenReturnsTrue()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_43EG);
_telescope.Connected = true;
_telescope.Park();
var result = _telescope.AtPark;
Assert.That(result, Is.True);
}
[TestCase(TelescopeAxes.axisPrimary, 4)]
[TestCase(TelescopeAxes.axisSecondary, 4)]
[TestCase(TelescopeAxes.axisTertiary, 0)]
public void AxisRates_ReturnsExpectedResult(TelescopeAxes axis, int expectedCount)
{
var result = _telescope.AxisRates(axis);
Assert.That(result.Count, Is.EqualTo(expectedCount));
}
[Test]
public void CanFindHome_Get_ReturnsFalse()
{
var result = _telescope.CanFindHome;
Assert.That(result, Is.False);
}
[TestCase(TelescopeAxes.axisPrimary, true)]
[TestCase(TelescopeAxes.axisSecondary, true)]
[TestCase(TelescopeAxes.axisTertiary, false)]
public void CanMoveAxis_ReturnsExpectedResult(TelescopeAxes axis, bool expected)
{
var result = _telescope.CanMoveAxis(axis);
Assert.That(result, Is.EqualTo(expected));
}
[Test]
public void CanPark_Get_ReturnsTrue()
{
var result = _telescope.CanPark;
Assert.That(result, Is.True);
}
[Test]
public void CanPulseGuide_Get_ReturnsTrue()
{
var result = _telescope.CanPulseGuide;
Assert.That(result, Is.True);
}
[Test]
public void CanSetDeclinationRate_Get_ReturnsFalse()
{
var result = _telescope.CanSetDeclinationRate;
Assert.That(result, Is.False);
}
[Test]
public void CanSetGuideRates_Get_ReturnsFalse()
{
var result = _telescope.CanSetGuideRates;
Assert.That(result, Is.False);
}
[Test]
public void CanSetPark_Get_ReturnsFalse()
{
var result = _telescope.CanSetPark;
Assert.That(result, Is.False);
}
[Test]
public void CanSetPierSide_Get_ReturnsFalse()
{
var result = _telescope.CanSetPierSide;
Assert.That(result, Is.False);
}
[Test]
public void CanSetRightAscensionRate_Get_ReturnsFalse()
{
var result = _telescope.CanSetRightAscensionRate;
Assert.That(result, Is.False);
}
[Test]
public void CanSetTracking_Get_ReturnsTrue()
{
var result = _telescope.CanSetTracking;
Assert.That(result, Is.True);
}
[Test]
public void CanSlew_Get_ReturnsTrue()
{
var result = _telescope.CanSlew;
Assert.That(result, Is.True);
}
[Test]
public void CanSlewAltAz_Get_ReturnsTrue()
{
var result = _telescope.CanSlewAltAz;
Assert.That(result, Is.True);
}
[Test]
public void CanSlewAltAzAsync_Get_ReturnsTrue()
{
var result = _telescope.CanSlewAltAzAsync;
Assert.That(result, Is.True);
}
[Test]
public void CanSlewAsync_Get_ReturnsTrue()
{
var result = _telescope.CanSlewAsync;
Assert.That(result, Is.True);
}
[Test]
public void CanSync_Get_ReturnsTrue()
{
var result = _telescope.CanSync;
Assert.That(result, Is.True);
}
[Test]
public void CanSyncAltAz_Get_ReturnsFalse()
{
var result = _telescope.CanSyncAltAz;
Assert.That(result, Is.False);
}
[Test]
public void CanUnpark_Get_ReturnsFalse()
{
var result = _telescope.CanUnpark;
Assert.That(result, Is.False);
}
[Test]
public void Declination_Get_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { var actualResult = _telescope.Declination; });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Declination Get"));
}
[TestCase("s12*34")]
[TestCase("s12*3456")]
public void Declination_Get_WhenConnected_ThenReadsValueFromScope(string declincationString)
{
var expectedResult = 12.34;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GD#")).Returns(declincationString);
_utilMock.Setup(x => x.DMSToDegrees(declincationString)).Returns(expectedResult);
var actualResult = _telescope.Declination;
Assert.That(actualResult, Is.EqualTo(expectedResult));
}
[Test]
public void DeclinationRate_Get_ThenReturns0()
{
var actualResult = _telescope.DeclinationRate;
Assert.That(actualResult, Is.EqualTo(0));
}
[Test]
public void DeclinationRate_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.DeclinationRate = 0; });
Assert.That(excpetion.Property, Is.EqualTo("DeclinationRate"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void DestinationSideOfPier_ThenThrowsException()
{
var excpetion = Assert.Throws<MethodNotImplementedException>(() => { var result = _telescope.DestinationSideOfPier(0,0); });
Assert.That(excpetion.Method, Is.EqualTo("DestinationSideOfPier"));
}
[Test]
public void DoesRefraction_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.DoesRefraction; });
Assert.That(excpetion.Property, Is.EqualTo("DoesRefraction"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void DoesRefraction_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.DoesRefraction = true; });
Assert.That(excpetion.Property, Is.EqualTo("DoesRefraction"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void EquatorialSystem_Get_ReturnsExpectedValue()
{
var actualResult = _telescope.EquatorialSystem;
Assert.That(actualResult, Is.EqualTo(EquatorialCoordinateType.equTopocentric));
}
[Test]
public void FindHome_ThenThrowsException()
{
var excpetion = Assert.Throws<MethodNotImplementedException>(() => { _telescope.FindHome();});
Assert.That(excpetion.Method, Is.EqualTo("FindHome"));
}
[Test]
public void FocalLength_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.FocalLength; });
Assert.That(excpetion.Property, Is.EqualTo("FocalLength"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void GuideRateDeclination_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.GuideRateDeclination; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void GuideRateDeclination_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateDeclination = 0; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateDeclination"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void GuideRateRightAscension_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.GuideRateRightAscension; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void GuideRateRightAscension_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.GuideRateRightAscension = 0; });
Assert.That(excpetion.Property, Is.EqualTo("GuideRateRightAscension"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void IsPulseGuiding_Get_ReturnsFalse()
{
var result = _telescope.IsPulseGuiding;
Assert.That(result, Is.False);
}
[Test]
public void MoveAxis_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { _telescope.MoveAxis(TelescopeAxes.axisPrimary, 0); });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: MoveAxis"));
}
[TestCase( 0, "", TelescopeAxes.axisPrimary)]
[TestCase( 1, ":RG#", TelescopeAxes.axisPrimary)]
[TestCase(-1, ":RG#", TelescopeAxes.axisPrimary)]
[TestCase( 2, ":RC#", TelescopeAxes.axisPrimary)]
[TestCase(-2, ":RC#", TelescopeAxes.axisPrimary)]
[TestCase( 3, ":RM#", TelescopeAxes.axisPrimary)]
[TestCase(-3, ":RM#", TelescopeAxes.axisPrimary)]
[TestCase( 4, ":RS#", TelescopeAxes.axisPrimary)]
[TestCase(-4, ":RS#", TelescopeAxes.axisPrimary)]
[TestCase(0, "", TelescopeAxes.axisSecondary)]
[TestCase(1, ":RG#", TelescopeAxes.axisSecondary)]
[TestCase(-1, ":RG#", TelescopeAxes.axisSecondary)]
[TestCase(2, ":RC#", TelescopeAxes.axisSecondary)]
[TestCase(-2, ":RC#", TelescopeAxes.axisSecondary)]
[TestCase(3, ":RM#", TelescopeAxes.axisSecondary)]
[TestCase(-3, ":RM#", TelescopeAxes.axisSecondary)]
[TestCase(4, ":RS#", TelescopeAxes.axisSecondary)]
[TestCase(-4, ":RS#", TelescopeAxes.axisSecondary)]
public void MoveAxis_WhenConnected_ThenExecutesCorrectCommandSequence(double rate, string slewRateCommand, TelescopeAxes axis)
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_telescope.MoveAxis(axis, rate);
if (slewRateCommand != string.Empty)
_sharedResourcesWrapperMock.Verify( x => x.SendBlind(slewRateCommand), Times.Once);
else
{
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RG#"), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RC#"), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RM#"), Times.Never);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RS#"), Times.Never);
}
switch (axis)
{
case TelescopeAxes.axisPrimary:
if (rate == 0)
{
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qe#"), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qw#"), Times.Once);
}
else if (rate > 0)
{
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Me#"), Times.Once);
}
else
{
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Mw#"), Times.Once);
}
break;
case TelescopeAxes.axisSecondary:
if (rate == 0)
{
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qn#"), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Qs#"), Times.Once);
}
else if (rate > 0)
{
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Mn#"), Times.Once);
}
else
{
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":Ms#"), Times.Once);
}
break;
default:
Assert.Fail("This should never happen");
break;
}
}
[Test]
public void MoveAxis_WhenRateTooHigh_ThenThrowsException()
{
var testRate = 5;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
var exception = Assert.Throws<InvalidValueException>( () => { _telescope.MoveAxis(TelescopeAxes.axisTertiary, testRate); });
Assert.That(exception.Message, Is.EqualTo($"Rate {testRate} not supported"));
}
[Test]
public void MoveAxis_WhenTertiaryAxis_ThenThrowsException()
{
var testRate = 0;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.MoveAxis(TelescopeAxes.axisTertiary, testRate); });
Assert.That(exception.Message, Is.EqualTo($"Can not move this axis."));
}
[Test]
public void Park_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { _telescope.Park(); });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Park"));
}
[Test]
public void Park_WhenNotParked_ThenSendsParkCommand()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
Assert.That(_telescope.AtPark, Is.False);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Never);
_telescope.Park();
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Once);
Assert.That(_telescope.AtPark, Is.True);
}
[Test]
public void Park_WhenParked_ThenDoesNothing()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_telescope.Park();
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Once);
Assert.That(_telescope.AtPark, Is.True);
//act
_telescope.Park();
//no change from previous state.
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":hP#"), Times.Once);
Assert.That(_telescope.AtPark, Is.True);
}
[Test]
public void PulseGuide_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { _telescope.PulseGuide(GuideDirections.guideEast,0); });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: PulseGuide"));
}
[TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)]
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenConnectedAndNewerPulseGuidingAvailable_ThenSendsNewCommandsAndWaits(GuideDirections direction)
{
var duration = 0;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_telescope.PulseGuide(direction, 0);
string d = string.Empty;
switch (direction)
{
case GuideDirections.guideEast:
d = "e";
break;
case GuideDirections.guideWest:
d = "w";
break;
case GuideDirections.guideNorth:
d = "n";
break;
case GuideDirections.guideSouth:
d = "s";
break;
}
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Mg{d}{duration:0000}#"));
_utilMock.Verify( x => x.WaitForMilliseconds(duration), Times.Once);
}
[TestCase(GuideDirections.guideEast)]
[TestCase(GuideDirections.guideWest)]
[TestCase(GuideDirections.guideNorth)]
[TestCase(GuideDirections.guideSouth)]
public void PulseGuide_WhenConnectedAndNewerPulseGuidingNotAvailable_ThenSendsOldCommandsAndWaits(GuideDirections direction)
{
var duration = 0;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => "31Ed");
_telescope.Connected = true;
_telescope.PulseGuide(direction, 0);
string d = string.Empty;
switch (direction)
{
case GuideDirections.guideEast:
d = "e";
break;
case GuideDirections.guideWest:
d = "w";
break;
case GuideDirections.guideNorth:
d = "n";
break;
case GuideDirections.guideSouth:
d = "s";
break;
}
_sharedResourcesWrapperMock.Verify(x => x.SendBlind(":RG#"));
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":M{d}#"));
_utilMock.Verify(x => x.WaitForMilliseconds(duration), Times.Once);
_sharedResourcesWrapperMock.Verify(x => x.SendBlind($":Q{d}#"));
}
[Test]
public void RightAscension_Get_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.RightAscension; });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: RightAscension Get"));
}
[Test]
public void RightAscension_Get_WhenConnected_ThenReturnsExpectedResult()
{
var telescopeRaResult = "HH:MM:SS";
var hmsResult = 1.2;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":GR#")).Returns(telescopeRaResult);
_utilMock.Setup(x => x.HMSToHours(telescopeRaResult)).Returns(hmsResult);
var result = _telescope.RightAscension;
_sharedResourcesWrapperMock.Verify( x => x.SendString(":GR#"), Times.Once);
_utilMock.Verify( x => x.HMSToHours(telescopeRaResult), Times.Once);
Assert.That(result,Is.EqualTo(hmsResult));
}
[Test]
public void RightAscensionRate_Get_ThenReturns0()
{
var result = _telescope.RightAscensionRate;
Assert.That(result, Is.EqualTo(0));
}
[Test]
public void RightAscensionRate_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.RightAscensionRate = 1; });
Assert.That(excpetion.Property, Is.EqualTo("RightAscensionRate"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void SetPark_ThenThrowsException()
{
var excpetion = Assert.Throws<MethodNotImplementedException>(() => { _telescope.SetPark(); });
Assert.That(excpetion.Method, Is.EqualTo("SetPark"));
}
[Test]
public void SideOfPier_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.SideOfPier; });
Assert.That(excpetion.Property, Is.EqualTo("SideOfPier"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void SideOfPier_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.SideOfPier = 0; });
Assert.That(excpetion.Property, Is.EqualTo("SideOfPier"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void SiteElevation_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.SiteElevation; });
Assert.That(excpetion.Property, Is.EqualTo("SiteElevation"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void SiteElevation_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.SiteElevation = 0; });
Assert.That(excpetion.Property, Is.EqualTo("SiteElevation"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void SlewSettleTime_Get_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { var result = _telescope.SlewSettleTime; });
Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime"));
Assert.That(excpetion.AccessorSet, Is.False);
}
[Test]
public void SlewSettleTime_Set_ThenThrowsException()
{
var excpetion = Assert.Throws<PropertyNotImplementedException>(() => { _telescope.SlewSettleTime = 0; });
Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime"));
Assert.That(excpetion.AccessorSet, Is.True);
}
[Test]
public void Unpark_ThenThrowsException()
{
var excpetion = Assert.Throws<MethodNotImplementedException>(() => { _telescope.Unpark(); });
Assert.That(excpetion.Method, Is.EqualTo("Unpark"));
}
[Test]
public void SiteLatitude_Get_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.SiteLatitude; });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLatitude Get"));
}
[Test]
public void SiteLatitude_Get_WhenConnected_ThenRetrievesAndReturnsExpectedValue()
{
var siteLatitudeString = "testLatString";
var siteLatitudeValue = 123.45;
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":Gt#")).Returns(siteLatitudeString);
_utilMock.Setup(x => x.DMSToDegrees(siteLatitudeString)).Returns(siteLatitudeValue);
var result = _telescope.SiteLatitude;
_sharedResourcesWrapperMock.Verify( x => x.SendString(":Gt#"), Times.Once);
Assert.That(result,Is.EqualTo(siteLatitudeValue));
}
[Test]
public void SiteLatitude_Set_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { _telescope.SiteLatitude = 123.45; });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLatitude Set"));
}
[Test]
public void SiteLatitude_Set_WhenConnectedAndLatitudeIsGreaterThan90_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.SiteLatitude = 90.01; });
Assert.That(exception.Message, Is.EqualTo("Latitude cannot be greater than 90 degrees."));
}
[Test]
public void SiteLatitude_Set_WhenConnectedAndLatitudeIsLessThanNegative90_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
var exception = Assert.Throws<InvalidValueException>(() => { _telescope.SiteLatitude = -90.01; });
Assert.That(exception.Message, Is.EqualTo("Latitude cannot be less than -90 degrees."));
}
[TestCase(-10.5)]
[TestCase(20.75)]
public void SiteLatitude_Set_WhenValueSetAndTelescopRejects_ThenExceptionThrown(double siteLatitude)
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Setup(x => x.SendChar(It.IsAny<string>())).Returns("0");
var exception = Assert.Throws<ASCOM.InvalidOperationException>(() => { _telescope.SiteLatitude = siteLatitude; });
Assert.That(exception.Message, Is.EqualTo("Failed to set site latitude."));
}
[TestCase(-10.5, ":St-10*30#")]
[TestCase(20.75, ":St+20*45#")]
public void SiteLatitude_Set_WhenValidValues_ThenValueSentToTelescope(double siteLatitude, string expectedCommand)
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Setup(x => x.SendChar(expectedCommand)).Returns("1");
_telescope.SiteLatitude = siteLatitude;
_sharedResourcesWrapperMock.Verify(x => x.SendChar(expectedCommand), Times.Once);
}
[Test]
public void SiteLongitude_Get_WhenNotConnected_ThenThrowsException()
{
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
var exception = Assert.Throws<NotConnectedException>(() => { var result = _telescope.SiteLongitude; });
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLongitude Get"));
}
//todo figure out if this is right. don't feel right to me
[TestCase("5", 5, -5)]
[TestCase("-5", -5, 5)]
[TestCase("185", 185, 175)]
[TestCase("350", 350, 10)]
public void SiteLongitude_Get_WhenConnected_ThenRetrivesAndReturnsExpectedValue(string telescopelongitudeString, double telescopeLongitudeValue, double expectedResult)
{
var telescopeLongitude = "testLongitude";
_sharedResourcesWrapperMock.Setup(x => x.ProductName).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497);
_sharedResourcesWrapperMock.Setup(x => x.FirmwareVersion).Returns(() => _sharedResourcesWrapperMock.Object.AUTOSTAR497_31EE);
_telescope.Connected = true;
_sharedResourcesWrapperMock.Setup(x => x.SendString(":Gg#")).Returns(telescopeLongitude);
_utilMock.Setup(x => x.DMSToDegrees(telescopeLongitude)).Returns(telescopeLongitudeValue);
var result = _telescope.SiteLongitude;
Assert.That(result, Is.EqualTo(expectedResult));
}
}
}
+12 -7
View File
@@ -822,7 +822,7 @@ namespace ASCOM.Meade.net
var result = _sharedResourcesWrapper.SendString(":GD#");
//:GD# Get Telescope Declination.
//Returns: sDD* MM# or sDD*MMSS#
//Returns: sDD*MM# or sDD*MMSS#
//Depending upon the current precision setting for the telescope.
double declination = _utilities.DMSToDegrees(result);
@@ -850,7 +850,7 @@ namespace ASCOM.Meade.net
public PierSide DestinationSideOfPier(double rightAscension, double declination)
{
LogMessage("DestinationSideOfPier Get", "Not implemented");
throw new ASCOM.PropertyNotImplementedException("DestinationSideOfPier", false);
throw new ASCOM.MethodNotImplementedException("DestinationSideOfPier");
}
public bool DoesRefraction
@@ -924,6 +924,7 @@ namespace ASCOM.Meade.net
{
get
{
//Todo implement this if I can make the new pulse guiding async
LogMessage("IsPulseGuiding Get", "pulse guiding is synchronous for this driver");
//throw new ASCOM.PropertyNotImplementedException("IsPulseGuiding", false);
return false;
@@ -1026,7 +1027,7 @@ namespace ASCOM.Meade.net
break;
default:
throw new ASCOM.MethodNotImplementedException("Can not move this axis.");
throw new ASCOM.InvalidValueException("Can not move this axis.");
}
}
@@ -1080,7 +1081,8 @@ namespace ASCOM.Meade.net
//Returns Nothing
//LX200 Not Supported
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
//todo implement IsPulseGuiding if WaitForMilliseconds is not needed
_utilities.WaitForMilliseconds(duration); //todo figure out if this is really needed
}
else
{
@@ -1232,10 +1234,13 @@ namespace ASCOM.Meade.net
throw new InvalidValueException("Latitude cannot be less than -90 degrees.");
string sign = value > 0 ? "+" : "-";
int d = Convert.ToInt32(Math.Floor(value));
int m = Convert.ToInt32(60 * (value - d));
var result = _sharedResourcesWrapper.SendChar($":St{sign}{d:00}*{m:00}#");
var absValue = Math.Abs(value);
int d = Convert.ToInt32(Math.Floor(absValue));
int m = Convert.ToInt32(60 * (absValue - d));
var commandString = $":St{sign}{d:00}*{m:00}#";
var result = _sharedResourcesWrapper.SendChar(commandString);
//:StsDD*MM#
//Sets the current site latitude to sDD* MM#
//Returns:
+6
View File
@@ -32,5 +32,11 @@
<include name="**/*" />
</fileset>
</copy>
<foreach item="File" in="${build.output.directory}" property="fileName">
<if test="${string::to-lower(path::get-extension(fileName)) == '.msi'}">
<move file="${fileName}" tofile="${path::combine(path::get-directory-name(fileName), path::get-file-name-without-extension(fileName) + '.' + environment::get-variable('BUILD_NUMBER') + '.msi')}" />
</if>
</foreach>
</target>
</project>