mirror of
https://bitbucket.org/cjdskunkworks/lynxastrodewcontroller.git
synced 2026-05-03 17:28:52 +00:00
Added missing build.build file and fixed a couple of broken unit tests.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using ASCOM.LynxAstro.DewController;
|
||||
using System.Collections.Generic;
|
||||
using ASCOM.LynxAstro.DewController;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -10,12 +11,22 @@ namespace LynxAstro.DewController.Switch.UnitTests
|
||||
private ASCOM.LynxAstro.DewController.Switch _switch;
|
||||
private Mock<ISharedResourcesWrapper> _sharedResourcesWrapperMock;
|
||||
|
||||
private ProfileProperties _profileProperties;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
||||
_profileProperties = new ProfileProperties()
|
||||
{
|
||||
ComPort = "TestCom1",
|
||||
SwitchNames = new List<string>(),
|
||||
TraceLogger = false
|
||||
};
|
||||
|
||||
_switch = new ASCOM.LynxAstro.DewController.Switch();
|
||||
_sharedResourcesWrapperMock = new Mock<ISharedResourcesWrapper>();
|
||||
_sharedResourcesWrapperMock.Setup(x => x.ReadProfile()).Returns(() => _profileProperties);
|
||||
|
||||
_switch = new ASCOM.LynxAstro.DewController.Switch(_sharedResourcesWrapperMock.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using ASCOM.LynxAstro.DewController;
|
||||
using ASCOM.Utilities.Interfaces;
|
||||
using Moq;
|
||||
@@ -99,7 +98,7 @@ namespace LynxAstro.DewController.UnitTests
|
||||
[Test]
|
||||
public void WriteProfile_WhenCalled_WritesExpectedProfileSettings()
|
||||
{
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
string DriverId = "ASCOM.LynxAstro.DewController.Switch";
|
||||
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
@@ -119,7 +118,7 @@ namespace LynxAstro.DewController.UnitTests
|
||||
|
||||
SharedResources.WriteProfile(profileProperties);
|
||||
|
||||
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
|
||||
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Switch"));
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "Trace Level", profileProperties.TraceLogger.ToString()), Times.Once);
|
||||
profileWrapperMock.Verify(x => x.WriteValue(DriverId, "COM Port", profileProperties.ComPort), Times.Once);
|
||||
}
|
||||
@@ -127,7 +126,7 @@ namespace LynxAstro.DewController.UnitTests
|
||||
[Test]
|
||||
public void ReadProfile_WhenCalled_ReturnsExpectedDefaultValues()
|
||||
{
|
||||
string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
string DriverId = "ASCOM.LynxAstro.DewController.Switch";
|
||||
|
||||
string ComPortDefault = "COM1";
|
||||
string TraceStateDefault = "false";
|
||||
@@ -140,24 +139,13 @@ namespace LynxAstro.DewController.UnitTests
|
||||
Mock<IProfileWrapper> profileWrapperMock = new Mock<IProfileWrapper>();
|
||||
profileWrapperMock.SetupAllProperties();
|
||||
|
||||
profileWrapperMock.Setup(x => x.DeviceType).Returns("Switch");
|
||||
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Trace Level", string.Empty, TraceStateDefault))
|
||||
.Returns(() =>
|
||||
TraceStateDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "COM Port", string.Empty, ComPortDefault))
|
||||
.Returns(ComPortDefault);
|
||||
profileWrapperMock
|
||||
.Setup(x => x.GetValue(DriverId, "Guide Rate Arc Seconds Per Second", string.Empty,
|
||||
GuideRateProfileNameDefault)).Returns(GuideRateProfileNameDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Precision", string.Empty, PrecisionDefault))
|
||||
.Returns(PrecisionDefault);
|
||||
profileWrapperMock.Setup(x => x.GetValue(DriverId, "Guiding Style", string.Empty, GuidingStyleDefault))
|
||||
.Returns(GuidingStyleDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Backlash Compensation", string.Empty, BacklashCompensationDefault))
|
||||
.Returns(BacklashCompensationDefault);
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, "Reverse Focuser Direction", string.Empty, ReverseFocuserDiectionDefault))
|
||||
.Returns(() => ReverseFocuserDiectionDefault);
|
||||
|
||||
profileWrapperMock.Setup(x =>
|
||||
x.GetValue(DriverId, It.IsRegex("^SwitchName_[0-9{1}]$"), string.Empty, It.IsAny<string>()))
|
||||
@@ -172,7 +160,7 @@ namespace LynxAstro.DewController.UnitTests
|
||||
|
||||
var profileProperties = SharedResources.ReadProfile();
|
||||
|
||||
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Telescope"));
|
||||
Assert.That(profeWrapper.DeviceType, Is.EqualTo("Switch"));
|
||||
Assert.That(profileProperties.ComPort, Is.EqualTo(ComPortDefault));
|
||||
Assert.That(profileProperties.TraceLogger, Is.EqualTo(bool.Parse(TraceStateDefault)));
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace ASCOM.LynxAstro.DewController
|
||||
|
||||
#region Profile
|
||||
|
||||
private const string DriverId = "ASCOM.MeadeGeneric.Telescope";
|
||||
private const string DriverId = "ASCOM.LynxAstro.DewController.Switch";
|
||||
|
||||
// Constants used for Profile persistence
|
||||
private const string ComPortProfileName = "COM Port";
|
||||
@@ -145,7 +145,7 @@ namespace ASCOM.LynxAstro.DewController
|
||||
{
|
||||
using (IProfileWrapper driverProfile = ProfileFactory.Create())
|
||||
{
|
||||
driverProfile.DeviceType = "Telescope";
|
||||
driverProfile.DeviceType = "Switch";
|
||||
driverProfile.WriteValue(DriverId, TraceStateProfileName, profileProperties.TraceLogger.ToString());
|
||||
driverProfile.WriteValue(DriverId, ComPortProfileName, profileProperties.ComPort);
|
||||
}
|
||||
@@ -164,7 +164,7 @@ namespace ASCOM.LynxAstro.DewController
|
||||
ProfileProperties profileProperties = new ProfileProperties();
|
||||
using (IProfileWrapper driverProfile = ProfileFactory.Create())
|
||||
{
|
||||
driverProfile.DeviceType = "Telescope";
|
||||
driverProfile.DeviceType = "Switch";
|
||||
profileProperties.ComPort = driverProfile.GetValue(DriverId, ComPortProfileName, string.Empty, ComPortDefault);
|
||||
profileProperties.TraceLogger = Convert.ToBoolean(driverProfile.GetValue(DriverId, TraceStateProfileName, string.Empty, TraceStateDefault));
|
||||
|
||||
@@ -181,6 +181,7 @@ namespace ASCOM.LynxAstro.DewController
|
||||
if (!finished)
|
||||
profileProperties.SwitchNames.Add(switchValue);
|
||||
|
||||
switchNo++;
|
||||
} while (!finished);
|
||||
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--EXTERNAL_PROPERTIES: outputDir-->
|
||||
<project name="LynxAstro.DewController" default="publish">
|
||||
|
||||
<property name="solution.directory" value="${directory::get-current-directory()}"/>
|
||||
<property name="build.output.directory" value="${solution.directory}\${outputDir}"/>
|
||||
|
||||
<target name="setup">
|
||||
<delete dir="${build.output.directory}"/>
|
||||
<mkdir dir="${build.output.directory}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile.application" depends="setup">
|
||||
<!-- compilation handled by TeamCity-->
|
||||
</target>
|
||||
|
||||
<target name="cleanup" depends="setup">
|
||||
<!-- no cleanup necessary-->
|
||||
</target>
|
||||
|
||||
<target name="publish" depends="cleanup">
|
||||
|
||||
<!-- publish -->
|
||||
<copy todir="${build.output.directory}">
|
||||
<fileset basedir="${solution.directory}\LynxAstro.DewController\bin\${configuration}">
|
||||
<include name="**/*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${build.output.directory}">
|
||||
<fileset basedir="${solution.directory}\LynxAstro.DewController.Switch\bin\${configuration}">
|
||||
<include name="**/*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<copy todir="${build.output.directory}">
|
||||
<fileset basedir="${solution.directory}\bin\${configuration}">
|
||||
<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>
|
||||
Reference in New Issue
Block a user