Code inspections

This commit is contained in:
2019-09-28 23:04:55 +01:00
parent 69fbb14410
commit 0bbfa5f9c3
3 changed files with 67 additions and 11 deletions
@@ -86,7 +86,11 @@ namespace Meade.net.Focuser.UnitTests
{
var actionName = "Action";
Assert.Throws<ActionNotImplementedException>(() => { var actualResult = _focuser.Action(actionName, string.Empty); });
Assert.Throws<ActionNotImplementedException>(() =>
{
var actualResult = _focuser.Action(actionName, string.Empty);
Assert.Fail($"{actualResult} should not have a value");
});
}
[Test]
@@ -277,7 +281,11 @@ namespace Meade.net.Focuser.UnitTests
[Test]
public void Absolute_Get_WhenNotConnected_ThenThrowsException()
{
var exception = Assert.Throws<NotConnectedException>(() => { var result = _focuser.Absolute; });
var exception = Assert.Throws<NotConnectedException>(() =>
{
var result = _focuser.Absolute;
Assert.Fail($"{result} should not have a value");
});
Assert.That(exception.Message, Is.EqualTo("Not connected to focuser when trying to execute: Absolute Get"));
}
@@ -413,14 +421,22 @@ namespace Meade.net.Focuser.UnitTests
[Test]
public void Position_WhenCalled_ThenThrowsException()
{
var exception = Assert.Throws<PropertyNotImplementedException>(() => { var result = _focuser.Position; });
var exception = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _focuser.Position;
Assert.Fail($"{result} should not have a value");
});
Assert.That(exception.Message, Is.EqualTo("Property read Position is not implemented in this driver."));
}
[Test]
public void StepSize_WhenCalled_ThenThrowsException()
{
var exception = Assert.Throws<PropertyNotImplementedException>(() => { var result = _focuser.StepSize; });
var exception = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _focuser.StepSize;
Assert.Fail($"{result} should not have a value");
});
Assert.That(exception.Message, Is.EqualTo("Property read StepSize is not implemented in this driver."));
}
@@ -448,7 +464,11 @@ namespace Meade.net.Focuser.UnitTests
[Test]
public void Temperature_WhenCalled_ThenThrowsException()
{
var exception = Assert.Throws<PropertyNotImplementedException>(() => { var result = _focuser.Temperature; });
var exception = Assert.Throws<PropertyNotImplementedException>(() =>
{
var result = _focuser.Temperature;
Assert.Fail($"{result} should not have a value");
});
Assert.That(exception.Message, Is.EqualTo("Property read Temperature is not implemented in this driver."));
}
}
+1 -6
View File
@@ -363,9 +363,6 @@ namespace ASCOM.Meade.net
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
finally
{
}
//
// For each of the driver assemblies
@@ -432,9 +429,7 @@ namespace ASCOM.Meade.net
DriverName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
bFail = true;
}
finally
{
}
if (bFail) break;
}
}
+41
View File
@@ -34,32 +34,73 @@ namespace ASCOM.Meade.net
static extern bool BringWindowToTop(IntPtr hWnd);
[DllImport("user32.dll")]
// ReSharper disable once UnusedMember.Local
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, Int32 nMaxCount);
[DllImport("user32.dll")]
// ReSharper disable once UnusedMember.Local
private static extern int GetWindowThreadProcessId(IntPtr hWnd, ref Int32 lpdwProcessId);
[DllImport("User32.dll")]
public static extern IntPtr GetParent(IntPtr hWnd);
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_HIDE = 0;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWNORMAL = 1;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_NORMAL = 1;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWMINIMIZED = 2;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWMAXIMIZED = 3;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_MAXIMIZE = 3;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWNOACTIVATE = 4;
// ReSharper disable once InconsistentNaming
private const int SW_SHOW = 5;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_MINIMIZE = 6;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWMINNOACTIVE = 7;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWNA = 8;
// ReSharper disable once InconsistentNaming
private const int SW_RESTORE = 9;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
// ReSharper disable once IdentifierTypo
private const int SW_SHOWDEFAULT = 10;
// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedMember.Local
private const int SW_MAX = 10;
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
private const uint SPI_GETFOREGROUNDLOCKTIMEOUT = 0x2000;
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
private const uint SPI_SETFOREGROUNDLOCKTIMEOUT = 0x2001;
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
private const int SPIF_SENDCHANGE = 0x2;