From 101784adb3731d6dd6ca25c4752429c16ef62d2d Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 28 Sep 2019 22:45:34 +0100 Subject: [PATCH] Code inspections --- .../TelescopeUnitTests.cs | 125 +++++++++++++++--- Meade.net.Telescope/Rates.cs | 2 +- 2 files changed, 105 insertions(+), 22 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index 416d6ac..4fa7bfd 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -105,7 +105,10 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Action_WhenNotConnected_ThrowsNotConnectedException() { - var exception = Assert.Throws(() => { var actualResult = _telescope.Action(string.Empty, string.Empty); }); + var exception = Assert.Throws(() => + { + _telescope.Action(string.Empty, string.Empty); + }); Assert.That(exception.Message,Is.EqualTo("Not connected to telescope when trying to execute: Action")); } @@ -552,7 +555,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void AlignmentMode_Get_WhenNotConnected_ThrowsException() { - var exception = Assert.Throws(() => { var actualResult = _telescope.AlignmentMode; }); + var exception = Assert.Throws(() => + { + var actualResult = _telescope.AlignmentMode; + Assert.Fail($"{actualResult} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: AlignmentMode Get")); } @@ -577,7 +584,11 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - Assert.Throws(() => { var actualResult = _telescope.AlignmentMode; }); + Assert.Throws(() => + { + var actualResult = _telescope.AlignmentMode; + Assert.Fail($"{actualResult} should not have returned"); + }); } [Test] @@ -617,7 +628,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void ApertureArea_Get_ThrowsNotImplementedException() { - var excpetion = Assert.Throws(() => { var result = _telescope.ApertureArea; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.ApertureArea; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("ApertureArea")); Assert.That(excpetion.AccessorSet, Is.False); @@ -626,7 +641,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void ApertureDiameter_Get_ThrowsNotImplementedException() { - var excpetion = Assert.Throws(() => { var result = _telescope.ApertureDiameter; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.ApertureDiameter; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("ApertureDiameter")); Assert.That(excpetion.AccessorSet, Is.False); @@ -714,7 +733,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void CanSetGuideRates_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.CanSetGuideRates; }); + var exception = Assert.Throws(() => + { + var result = _telescope.CanSetGuideRates; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: CanSetGuideRates Get")); } @@ -883,7 +906,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Declination_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var actualResult = _telescope.Declination; }); + var exception = Assert.Throws(() => + { + var actualResult = _telescope.Declination; + Assert.Fail($"{actualResult} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Declination Get")); } @@ -921,7 +948,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void DestinationSideOfPier_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.DestinationSideOfPier(0,0); }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.DestinationSideOfPier(0,0); + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Method, Is.EqualTo("DestinationSideOfPier")); } @@ -929,7 +960,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void DoesRefraction_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.DoesRefraction; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.DoesRefraction; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("DoesRefraction")); Assert.That(excpetion.AccessorSet, Is.False); @@ -963,7 +998,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void FocalLength_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.FocalLength; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.FocalLength; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("FocalLength")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1300,7 +1339,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void RightAscension_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.RightAscension; }); + var exception = Assert.Throws(() => + { + var result = _telescope.RightAscension; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: RightAscension Get")); } @@ -1351,7 +1394,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SideOfPier_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.SideOfPier; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.SideOfPier; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("SideOfPier")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1369,7 +1416,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SiteElevation_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.SiteElevation; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.SiteElevation; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("SiteElevation")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1387,7 +1438,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SlewSettleTime_Get_ThenThrowsException() { - var excpetion = Assert.Throws(() => { var result = _telescope.SlewSettleTime; }); + var excpetion = Assert.Throws(() => + { + var result = _telescope.SlewSettleTime; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(excpetion.Property, Is.EqualTo("SlewSettleTime")); Assert.That(excpetion.AccessorSet, Is.False); @@ -1413,7 +1468,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SiteLatitude_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.SiteLatitude; }); + var exception = Assert.Throws(() => + { + var result = _telescope.SiteLatitude; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLatitude Get")); } @@ -1488,7 +1547,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void SiteLongitude_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.SiteLongitude; }); + var exception = Assert.Throws(() => + { + var result = _telescope.SiteLongitude; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: SiteLongitude Get")); } @@ -1659,7 +1722,11 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - var exception = Assert.Throws(() => { var result = _telescope.TargetDeclination; }); + var exception = Assert.Throws(() => + { + var result = _telescope.TargetDeclination; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Target not set")); } @@ -1733,7 +1800,11 @@ namespace Meade.net.Telescope.UnitTests { ConnectTelescope(); - var exception = Assert.Throws(() => { var result = _telescope.TargetRightAscension; }); + var exception = Assert.Throws(() => + { + var result = _telescope.TargetRightAscension; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Target not set")); } @@ -1830,7 +1901,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void UTCDate_Get_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.UTCDate; }); + var exception = Assert.Throws(() => + { + var result = _telescope.UTCDate; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: UTCDate Get")); } @@ -2315,7 +2390,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Azimuth_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.Azimuth; }); + var exception = Assert.Throws(() => + { + var result = _telescope.Azimuth; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Azimuth Get")); } @@ -2356,7 +2435,11 @@ namespace Meade.net.Telescope.UnitTests [Test] public void Altitude_WhenNotConnected_ThenThrowsException() { - var exception = Assert.Throws(() => { var result = _telescope.Altitude; }); + var exception = Assert.Throws(() => + { + var result = _telescope.Altitude; + Assert.Fail($"{result} should not have returned"); + }); Assert.That(exception.Message, Is.EqualTo("Not connected to telescope when trying to execute: Altitude Get")); } diff --git a/Meade.net.Telescope/Rates.cs b/Meade.net.Telescope/Rates.cs index d9fcefa..c656683 100644 --- a/Meade.net.Telescope/Rates.cs +++ b/Meade.net.Telescope/Rates.cs @@ -170,7 +170,7 @@ namespace ASCOM.Meade.net _pos.Value = -1; } - return this as IEnumerator; + return this; } public void Dispose()