2025-09-02 20:31:30 -04:00
|
|
|
|
using System.IO;
|
2024-12-02 11:07:01 -05:00
|
|
|
|
using BinaryObjectScanner.FileType;
|
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BinaryObjectScanner.Test.FileType
|
|
|
|
|
|
{
|
2025-09-06 09:53:34 -04:00
|
|
|
|
public class LinearExecutableTests
|
2024-12-02 11:07:01 -05:00
|
|
|
|
{
|
2025-09-06 10:40:26 -04:00
|
|
|
|
private static readonly SabreTools.Serialization.Wrappers.LinearExecutable wrapper
|
2025-09-29 08:01:50 -04:00
|
|
|
|
= new(new SabreTools.Data.Models.LinearExecutable.Executable(), new MemoryStream(new byte[1024]));
|
2025-09-06 10:40:26 -04:00
|
|
|
|
|
2024-12-02 11:07:01 -05:00
|
|
|
|
[Fact]
|
2024-12-02 11:21:14 -05:00
|
|
|
|
public void DetectFile_EmptyString_Null()
|
2024-12-02 11:07:01 -05:00
|
|
|
|
{
|
|
|
|
|
|
string file = string.Empty;
|
2025-09-06 10:40:26 -04:00
|
|
|
|
var detectable = new LinearExecutable(wrapper);
|
2024-12-02 11:07:01 -05:00
|
|
|
|
|
|
|
|
|
|
string? actual = detectable.Detect(file, includeDebug: false);
|
|
|
|
|
|
Assert.Null(actual);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2025-09-06 10:40:26 -04:00
|
|
|
|
public void DetectStream_EmptyStream_Empty()
|
2024-12-02 11:07:01 -05:00
|
|
|
|
{
|
|
|
|
|
|
Stream? stream = new MemoryStream();
|
|
|
|
|
|
string file = string.Empty;
|
2025-09-06 10:40:26 -04:00
|
|
|
|
var detectable = new LinearExecutable(wrapper);
|
2024-12-02 11:07:01 -05:00
|
|
|
|
|
|
|
|
|
|
string? actual = detectable.Detect(stream, file, includeDebug: false);
|
2025-09-06 10:40:26 -04:00
|
|
|
|
Assert.NotNull(actual);
|
|
|
|
|
|
Assert.Empty(actual);
|
2024-12-02 11:07:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|