Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee60613a95 | |||
| a6308f1a64 | |||
| 0475217d62 |
@@ -9,6 +9,7 @@ using ASCOM.Meade.net.Wrapper;
|
|||||||
using ASCOM.Utilities.Interfaces;
|
using ASCOM.Utilities.Interfaces;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using InvalidOperationException = ASCOM.InvalidOperationException;
|
||||||
using NotImplementedException = ASCOM.NotImplementedException;
|
using NotImplementedException = ASCOM.NotImplementedException;
|
||||||
|
|
||||||
namespace Meade.net.Telescope.UnitTests
|
namespace Meade.net.Telescope.UnitTests
|
||||||
@@ -1323,5 +1324,64 @@ namespace Meade.net.Telescope.UnitTests
|
|||||||
|
|
||||||
Assert.That(result, Is.EqualTo(expectedResult));
|
Assert.That(result, Is.EqualTo(expectedResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SiteLongitude_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.SiteLongitude = 123.45; });
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLongitude Set"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SiteLongitude_Set_WhenConnectedAndGreaterThan180_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.SiteLongitude = 180.1; });
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Longitude cannot be greater than 180 degrees."));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SiteLongitude_Set_WhenConnectedAndLessThanNegative180_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.SiteLongitude = -180.1; });
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Longitude cannot be lower than -180 degrees."));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SiteLongitude_Set_WhenConnectedAndTelescopeFails_ThenThrowsException()
|
||||||
|
{
|
||||||
|
_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<InvalidOperationException>(() => { _telescope.SiteLongitude = 10; });
|
||||||
|
Assert.That(exception.Message, Is.EqualTo("Failed to set site longitude."));
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(10, ":Sg350*00#")]
|
||||||
|
public void SiteLongitude_Set_WhenConnectedAndTelescopeFails_ThenThrowsException(double longitude, 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.SiteLongitude = longitude;
|
||||||
|
|
||||||
|
_sharedResourcesWrapperMock.Verify(x => x.SendChar(expectedCommand), Times.Once);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1293,7 +1293,9 @@ namespace ASCOM.Meade.net
|
|||||||
int d = Convert.ToInt32(Math.Floor(newLongitude));
|
int d = Convert.ToInt32(Math.Floor(newLongitude));
|
||||||
int m = Convert.ToInt32(60 * (newLongitude - d));
|
int m = Convert.ToInt32(60 * (newLongitude - d));
|
||||||
|
|
||||||
var result = _sharedResourcesWrapper.SendChar($":Sg{d:000}*{m:00}#");
|
var commandstring = $":Sg{d:000}*{m:00}#";
|
||||||
|
|
||||||
|
var result = _sharedResourcesWrapper.SendChar(commandstring);
|
||||||
//:SgDDD*MM#
|
//:SgDDD*MM#
|
||||||
//Set current site’s longitude to DDD*MM an ASCII position string
|
//Set current site’s longitude to DDD*MM an ASCII position string
|
||||||
//Returns:
|
//Returns:
|
||||||
|
|||||||
+1
-2
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
<property name="solution.directory" value="${directory::get-current-directory()}"/>
|
<property name="solution.directory" value="${directory::get-current-directory()}"/>
|
||||||
<property name="build.output.directory" value="${solution.directory}\${outputDir}"/>
|
<property name="build.output.directory" value="${solution.directory}\${outputDir}"/>
|
||||||
<property name="AssemblyVersionUpdater" value="${build.number}"/>
|
|
||||||
|
|
||||||
<target name="setup">
|
<target name="setup">
|
||||||
<delete dir="${build.output.directory}"/>
|
<delete dir="${build.output.directory}"/>
|
||||||
@@ -36,7 +35,7 @@
|
|||||||
|
|
||||||
<foreach item="File" in="${build.output.directory}" property="fileName">
|
<foreach item="File" in="${build.output.directory}" property="fileName">
|
||||||
<if test="${string::to-lower(path::get-extension(fileName)) == '.msi'}">
|
<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) + '${AssemblyVersionUpdater}.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>
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
Reference in New Issue
Block a user