2024-12-02 11:07:01 -05:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using BinaryObjectScanner.FileType;
|
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BinaryObjectScanner.Test.FileType
|
|
|
|
|
|
{
|
|
|
|
|
|
public class RARTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[Fact]
|
2024-12-02 11:21:14 -05:00
|
|
|
|
public void ExtractFile_EmptyString_False()
|
2024-12-02 11:07:01 -05:00
|
|
|
|
{
|
|
|
|
|
|
string file = string.Empty;
|
|
|
|
|
|
string outDir = string.Empty;
|
|
|
|
|
|
var extractable = new RAR();
|
|
|
|
|
|
|
|
|
|
|
|
bool actual = extractable.Extract(file, outDir, includeDebug: false);
|
|
|
|
|
|
Assert.False(actual);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 11:21:14 -05:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void ExtractFile_LookForHeader_EmptyString_False()
|
|
|
|
|
|
{
|
|
|
|
|
|
string file = string.Empty;
|
|
|
|
|
|
string outDir = string.Empty;
|
|
|
|
|
|
var extractable = new RAR();
|
|
|
|
|
|
|
|
|
|
|
|
bool actual = extractable.Extract(file, outDir, lookForHeader: true, includeDebug: false);
|
|
|
|
|
|
Assert.False(actual);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 11:07:01 -05:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void ExtractStream_Null_False()
|
|
|
|
|
|
{
|
|
|
|
|
|
Stream? stream = null;
|
|
|
|
|
|
string file = string.Empty;
|
|
|
|
|
|
string outDir = string.Empty;
|
|
|
|
|
|
var extractable = new RAR();
|
|
|
|
|
|
|
|
|
|
|
|
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
|
|
|
|
|
|
Assert.False(actual);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 11:21:14 -05:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void ExtractStream_LookForHeader_Null_False()
|
|
|
|
|
|
{
|
|
|
|
|
|
Stream? stream = null;
|
|
|
|
|
|
string file = string.Empty;
|
|
|
|
|
|
string outDir = string.Empty;
|
|
|
|
|
|
var extractable = new RAR();
|
|
|
|
|
|
|
|
|
|
|
|
bool actual = extractable.Extract(stream, file, outDir, lookForHeader: true, includeDebug: false);
|
|
|
|
|
|
Assert.False(actual);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 11:07:01 -05:00
|
|
|
|
[Fact]
|
|
|
|
|
|
public void ExtractStream_Empty_False()
|
|
|
|
|
|
{
|
|
|
|
|
|
Stream? stream = new MemoryStream();
|
|
|
|
|
|
string file = string.Empty;
|
|
|
|
|
|
string outDir = string.Empty;
|
|
|
|
|
|
var extractable = new RAR();
|
|
|
|
|
|
|
|
|
|
|
|
bool actual = extractable.Extract(stream, file, outDir, includeDebug: false);
|
|
|
|
|
|
Assert.False(actual);
|
|
|
|
|
|
}
|
2024-12-02 11:21:14 -05:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void ExtractStream_LookForHeader_Empty_False()
|
|
|
|
|
|
{
|
|
|
|
|
|
Stream? stream = new MemoryStream();
|
|
|
|
|
|
string file = string.Empty;
|
|
|
|
|
|
string outDir = string.Empty;
|
|
|
|
|
|
var extractable = new RAR();
|
|
|
|
|
|
|
|
|
|
|
|
bool actual = extractable.Extract(stream, file, outDir, lookForHeader: true, includeDebug: false);
|
|
|
|
|
|
Assert.False(actual);
|
|
|
|
|
|
}
|
2024-12-02 11:07:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|