using RioJoy.Core.Protocol;
using Xunit;

namespace RioJoy.Core.Tests.Protocol;

public class RioRepliesTests
{
    [Fact]
    public void VersionInfo_ParsesMajorMinor()
    {
        VersionInfo v = VersionInfo.Parse(new byte[] { 0, 3 });
        Assert.Equal(0, v.Major);
        Assert.Equal(3, v.Minor);
        Assert.Equal("0.3", v.ToString());
    }

    [Fact]
    public void CheckStatus_ParsesTypeAndNumber()
    {
        CheckStatus s = CheckStatus.Parse(new byte[] { (byte)RioStatusType.BoardMissing, 7 });
        Assert.Equal(RioStatusType.BoardMissing, s.Type);
        Assert.Equal(7, s.Number);
    }

    [Fact]
    public void Parse_RejectsWrongLength()
    {
        Assert.Throws<ArgumentException>(() => VersionInfo.Parse(new byte[] { 1 }));
        Assert.Throws<ArgumentException>(() => CheckStatus.Parse(new byte[] { 1, 2, 3 }));
    }
}
