mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-20 18:02:16 +00:00
0c70e11fe8
- CS8604: Use cmdlet's own Node property instead of nullable task.Node in WaitForTask calls across all VM cmdlets - CS8618: Make PveSession.ServerVersion nullable (PveVersion?) since it is set post-construction by PveAuthenticator - CS8603: Add null-forgiving operator where IsNullOrWhiteSpace guards guarantee non-null in PveHttpClient - CS1573: Add XML param documentation to all public service methods - xUnit1012: Make test parameters nullable (string?) for null test cases Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
92 lines
2.3 KiB
C#
92 lines
2.3 KiB
C#
using System;
|
|
using Xunit;
|
|
using PSProxmoxVE.Core.Authentication;
|
|
|
|
namespace PSProxmoxVE.Core.Tests.Authentication
|
|
{
|
|
public class PveVersionTests
|
|
{
|
|
[Fact]
|
|
public void Parse_ValidVersion_9_1()
|
|
{
|
|
var version = PveVersion.Parse("9.1-1");
|
|
Assert.Equal(9, version.Major);
|
|
Assert.Equal(1, version.Minor);
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_ValidVersion_8_3()
|
|
{
|
|
var version = PveVersion.Parse("8.3-2");
|
|
Assert.Equal(8, version.Major);
|
|
Assert.Equal(3, version.Minor);
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_ValidVersion_8_0()
|
|
{
|
|
var version = PveVersion.Parse("8.0-1");
|
|
Assert.Equal(8, version.Major);
|
|
Assert.Equal(0, version.Minor);
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_NoPatchLevel()
|
|
{
|
|
var version = PveVersion.Parse("9.1");
|
|
Assert.Equal(9, version.Major);
|
|
Assert.Equal(1, version.Minor);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
public void Parse_NullOrEmpty_Throws(string? input)
|
|
{
|
|
Assert.Throws<ArgumentException>(() => PveVersion.Parse(input));
|
|
}
|
|
|
|
[Fact]
|
|
public void Parse_InvalidFormat_Throws()
|
|
{
|
|
Assert.Throws<FormatException>(() => PveVersion.Parse("invalid"));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsAtLeast_True_SameMajorLowerMinor()
|
|
{
|
|
var version = PveVersion.Parse("9.1-1");
|
|
Assert.True(version.IsAtLeast(9, 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsAtLeast_True_LowerMajor()
|
|
{
|
|
var version = PveVersion.Parse("9.1-1");
|
|
Assert.True(version.IsAtLeast(8, 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsAtLeast_False()
|
|
{
|
|
var version = PveVersion.Parse("8.3-2");
|
|
Assert.False(version.IsAtLeast(9, 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsAtLeast_ExactMatch()
|
|
{
|
|
var version = PveVersion.Parse("8.0-1");
|
|
Assert.True(version.IsAtLeast(8, 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void ToString_Format()
|
|
{
|
|
var version = PveVersion.Parse("9.1-1");
|
|
Assert.Equal("9.1", version.ToString());
|
|
}
|
|
}
|
|
}
|