From 0bbfa5f9c3b73913ca4400c3d4285187c0e96f64 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 23:04:55 +0100 Subject: [PATCH] Code inspections --- .../FocuserUnitTests.cs | 30 +++++++++++--- Meade.net/LocalServer.cs | 7 +--- Meade.net/Win32Utilities.cs | 41 +++++++++++++++++++ 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs index 58bf548..66c5621 100644 --- a/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs +++ b/Meade.net.Focuser.UnitTests/FocuserUnitTests.cs @@ -86,7 +86,11 @@ namespace Meade.net.Focuser.UnitTests { var actionName = "Action"; - Assert.Throws(() => { var actualResult = _focuser.Action(actionName, string.Empty); }); + Assert.Throws(() => + { + 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(() => { var result = _focuser.Absolute; }); + var exception = Assert.Throws(() => + { + 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(() => { var result = _focuser.Position; }); + var exception = Assert.Throws(() => + { + 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(() => { var result = _focuser.StepSize; }); + var exception = Assert.Throws(() => + { + 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(() => { var result = _focuser.Temperature; }); + var exception = Assert.Throws(() => + { + 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.")); } } diff --git a/Meade.net/LocalServer.cs b/Meade.net/LocalServer.cs index e321c59..8635814 100644 --- a/Meade.net/LocalServer.cs +++ b/Meade.net/LocalServer.cs @@ -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; } } diff --git a/Meade.net/Win32Utilities.cs b/Meade.net/Win32Utilities.cs index 959528a..b5b5ffa 100644 --- a/Meade.net/Win32Utilities.cs +++ b/Meade.net/Win32Utilities.cs @@ -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;