mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-10 06:16:53 +00:00
c1a9dd5ca1
144 tests covering authentication (version parsing, session expiry, token format validation), model deserialization from real PVE 8.x/9.x API JSON fixtures, and service layer behavior. Includes TestHelper with mock HttpMessageHandler factory and 21 JSON fixture files. 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());
|
|
}
|
|
}
|
|
}
|