Remove some unused runtime properties and add some tests

This commit is contained in:
Caelan Sayler
2024-01-08 11:49:46 +00:00
parent 5dfb761fbc
commit 8cf8b59142
2 changed files with 45 additions and 21 deletions

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Velopack.Tests
{
public class RuntimeInfoTests
{
[Fact]
public void NugetVersionAgreesWithNbgv()
{
var args = new List<string> { "get-version", "-v", "NuGetPackageVersion" };
var current = new ProcessStartInfo("nbgv", args).Output(5000);
Assert.Equal(current, VelopackRuntimeInfo.VelopackNugetVersion.ToString());
}
[Fact]
public void PlatformIsCorrect()
{
#if NETFRAMEWORK
Assert.True(VelopackRuntimeInfo.IsWindows);
Assert.Equal(RuntimeOs.Windows, VelopackRuntimeInfo.SystemOs);
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
Assert.True(VelopackRuntimeInfo.IsWindows);
Assert.Equal(RuntimeOs.Windows, VelopackRuntimeInfo.SystemOs);
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
Assert.True(VelopackRuntimeInfo.IsLinux);
Assert.Equal(RuntimeOs.Linux, VelopackRuntimeInfo.SystemOs);
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
Assert.True(VelopackRuntimeInfo.IsOSX);
Assert.Equal(RuntimeOs.OSX, VelopackRuntimeInfo.SystemOs);
} else {
throw new PlatformNotSupportedException();
}
#endif
}
}
}