From 99d9e709216e8689b2f69cd2ccc96620567c5f07 Mon Sep 17 00:00:00 2001 From: xRushG <145561288+xRushG@users.noreply.github.com> Date: Wed, 29 May 2024 15:20:56 +0200 Subject: [PATCH] Fix #2592: Prevent GeneralAppInfo.ApplicationVersion from being set in Unit Tests. Not needed for tests. --- mRemoteNGTests/App/UpdaterTests.cs | 32 ++++++++---------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/mRemoteNGTests/App/UpdaterTests.cs b/mRemoteNGTests/App/UpdaterTests.cs index c4c01c7a..80ee0914 100644 --- a/mRemoteNGTests/App/UpdaterTests.cs +++ b/mRemoteNGTests/App/UpdaterTests.cs @@ -9,75 +9,59 @@ namespace mRemoteNGTests.App; [TestFixture] public class UpdaterTests { + private readonly Version TestApplicationVersion = new("1.0.0.0"); + [Test] public void UpdateStableChannel() { - GeneralAppInfo.ApplicationVersion = "1.0.0.0"; var CurrentUpdateInfo = UpdateInfo.FromString(Resources.update); Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True); - Version v; - Version.TryParse(GeneralAppInfo.ApplicationVersion, out v); - var IsNewer = CurrentUpdateInfo.Version > v; + bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion; Assert.That(IsNewer, Is.True); } [Test] public void UpdateBetaChannel() { - GeneralAppInfo.ApplicationVersion = "1.0.0.0"; var CurrentUpdateInfo = UpdateInfo.FromString(Resources.beta_update); Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True); - Version v; - Version.TryParse(GeneralAppInfo.ApplicationVersion, out v); - var IsNewer = CurrentUpdateInfo.Version > v; + bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion; Assert.That(IsNewer, Is.True); } [Test] public void UpdateDevChannel() { - GeneralAppInfo.ApplicationVersion = "1.0.0.0"; var CurrentUpdateInfo = UpdateInfo.FromString(Resources.dev_update); Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True); - Version v; - Version.TryParse(GeneralAppInfo.ApplicationVersion, out v); - var IsNewer = CurrentUpdateInfo.Version > v; + bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion; Assert.That(IsNewer, Is.True); } [Test] public void UpdateStablePortableChannel() { - GeneralAppInfo.ApplicationVersion = "1.0.0.0"; var CurrentUpdateInfo = UpdateInfo.FromString(Resources.update_portable); Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True); - Version v; - Version.TryParse(GeneralAppInfo.ApplicationVersion, out v); - var IsNewer = CurrentUpdateInfo.Version > v; + bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion; Assert.That(IsNewer, Is.True); } [Test] public void UpdateBetaPortableChannel() { - GeneralAppInfo.ApplicationVersion = "1.0.0.0"; var CurrentUpdateInfo = UpdateInfo.FromString(Resources.beta_update_portable); Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True); - Version v; - Version.TryParse(GeneralAppInfo.ApplicationVersion, out v); - var IsNewer = CurrentUpdateInfo.Version > v; + bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion; Assert.That(IsNewer, Is.True); } [Test] public void UpdateDevPortableChannel() { - GeneralAppInfo.ApplicationVersion = "1.0.0.0"; var CurrentUpdateInfo = UpdateInfo.FromString(Resources.dev_update_portable); Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True); - Version v; - Version.TryParse(GeneralAppInfo.ApplicationVersion, out v); - var IsNewer = CurrentUpdateInfo.Version > v; + bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion; Assert.That(IsNewer, Is.True); } } \ No newline at end of file