diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/DotnetVersionCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/DotnetVersionCheckFixture.cs new file mode 100644 index 000000000..2f7386b48 --- /dev/null +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/DotnetVersionCheckFixture.cs @@ -0,0 +1,69 @@ +using System; +using NUnit.Framework; +using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Core.HealthCheck.Checks; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.HealthCheck.Checks +{ + [TestFixture] + public class DotnetVersionCheckFixture : CoreTest + { + private void GivenOutput(string version) + { + WindowsOnly(); + + Mocker.GetMock() + .SetupGet(s => s.Version) + .Returns(new Version(version)); + } + + [TestCase("4.7.2")] + [TestCase("4.8")] + public void should_return_ok(string version) + { + GivenOutput(version); + + Subject.Check().ShouldBeOk(); + } + + [TestCase("4.6.2")] + [TestCase("4.7")] + [TestCase("4.7.1")] + public void should_return_notice(string version) + { + GivenOutput(version); + + Subject.Check().ShouldBeNotice(); + } + + public void should_return_warning(string version) + { + GivenOutput(version); + + Subject.Check().ShouldBeWarning(); + } + + [TestCase("4.5")] + [TestCase("4.5.2")] + [TestCase("4.6.1")] + public void should_return_error(string version) + { + GivenOutput(version); + + Subject.Check().ShouldBeError(); + } + + [Test] + public void should_return_ok_for_net462_on_Win1511() + { + Mocker.GetMock() + .SetupGet(v => v.Version) + .Returns("10.0.14392"); + + GivenOutput("4.6.2"); + + Subject.Check().ShouldBeOk(); + } + } +} diff --git a/src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs index 212af2317..3c4279d4c 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs @@ -7,11 +7,13 @@ namespace NzbDrone.Core.HealthCheck.Checks public class DotnetVersionCheck : HealthCheckBase { private readonly IPlatformInfo _platformInfo; + private readonly IOsInfo _osInfo; private readonly Logger _logger; - public DotnetVersionCheck(IPlatformInfo platformInfo, Logger logger) + public DotnetVersionCheck(IPlatformInfo platformInfo, IOsInfo osInfo, Logger logger) { _platformInfo = platformInfo; + _osInfo = osInfo; _logger = logger; } @@ -26,6 +28,12 @@ public override HealthCheck Check() // Target .Net version, which would allow us to increase our target framework var targetVersion = new Version("4.7.2"); + if (Version.TryParse(_osInfo.Version, out var osVersion) && osVersion < new Version("10.0.14393")) + { + // Windows 10 LTSB 1511 and before do not support 4.7.x + targetVersion = new Version("4.6.2"); + } + if (dotnetVersion >= targetVersion) { _logger.Debug("Dotnet version is {0} or better: {1}", targetVersion, dotnetVersion);