2025-08-26 21:14:25 -04:00
|
|
|
using System;
|
2025-08-23 11:55:54 -04:00
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2026-01-27 12:03:01 -05:00
|
|
|
#pragma warning disable xUnit1004 // Test methods should not be skipped
|
2026-03-18 16:37:59 -04:00
|
|
|
namespace SabreTools.Wrappers.Test
|
2025-08-23 11:55:54 -04:00
|
|
|
{
|
|
|
|
|
public class RARTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void NullArray_Null()
|
|
|
|
|
{
|
|
|
|
|
byte[]? data = null;
|
|
|
|
|
int offset = 0;
|
|
|
|
|
var actual = RAR.Create(data, offset);
|
|
|
|
|
Assert.Null(actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void EmptyArray_Null()
|
|
|
|
|
{
|
|
|
|
|
byte[]? data = [];
|
|
|
|
|
int offset = 0;
|
|
|
|
|
var actual = RAR.Create(data, offset);
|
|
|
|
|
Assert.Null(actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact(Skip = "This will never pass with the current code")]
|
|
|
|
|
public void InvalidArray_Null()
|
|
|
|
|
{
|
|
|
|
|
byte[]? data = [.. Enumerable.Repeat<byte>(0xFF, 1024)];
|
|
|
|
|
int offset = 0;
|
|
|
|
|
var actual = RAR.Create(data, offset);
|
|
|
|
|
Assert.Null(actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void NullStream_Null()
|
|
|
|
|
{
|
|
|
|
|
Stream? data = null;
|
|
|
|
|
var actual = RAR.Create(data);
|
|
|
|
|
Assert.Null(actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact(Skip = "This will never pass with the current code")]
|
|
|
|
|
public void EmptyStream_Null()
|
|
|
|
|
{
|
|
|
|
|
Stream? data = new MemoryStream([]);
|
|
|
|
|
var actual = RAR.Create(data);
|
|
|
|
|
Assert.Null(actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact(Skip = "This will never pass with the current code")]
|
|
|
|
|
public void InvalidStream_Null()
|
|
|
|
|
{
|
|
|
|
|
Stream? data = new MemoryStream([.. Enumerable.Repeat<byte>(0xFF, 1024)]);
|
|
|
|
|
var actual = RAR.Create(data);
|
|
|
|
|
Assert.Null(actual);
|
|
|
|
|
}
|
2025-08-26 21:14:25 -04:00
|
|
|
|
|
|
|
|
#region FindParts
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("single.rar", 1)]
|
|
|
|
|
[InlineData("multi-old.rar", 4)]
|
|
|
|
|
[InlineData("multi-new.part01.rar", 3)]
|
|
|
|
|
[InlineData("multi-split.rar.001", 3)]
|
|
|
|
|
public void FindPartsTest(string filename, int expectedParts)
|
|
|
|
|
{
|
|
|
|
|
string firstPart = Path.Combine(Environment.CurrentDirectory, "TestData", "RAR", filename);
|
|
|
|
|
var actual = RAR.FindParts(firstPart);
|
|
|
|
|
Assert.Equal(expectedParts, actual.Count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2025-08-23 11:55:54 -04:00
|
|
|
}
|
2025-11-14 09:06:59 -05:00
|
|
|
}
|