From 95f152c105963eed601fa249e6aca502e4cab08b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 17 Mar 2026 14:30:34 -0400 Subject: [PATCH] Add GCF tests --- BinaryObjectScanner.Test/FileType/GCFTests.cs | 33 +++++++++++++++++++ BinaryObjectScanner/FileType/GCF.cs | 11 ++++--- 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 BinaryObjectScanner.Test/FileType/GCFTests.cs diff --git a/BinaryObjectScanner.Test/FileType/GCFTests.cs b/BinaryObjectScanner.Test/FileType/GCFTests.cs new file mode 100644 index 00000000..0edfe905 --- /dev/null +++ b/BinaryObjectScanner.Test/FileType/GCFTests.cs @@ -0,0 +1,33 @@ +using System.IO; +using BinaryObjectScanner.FileType; +using Xunit; + +namespace BinaryObjectScanner.Test.FileType +{ + public class GCFTests + { + private static readonly SabreTools.Serialization.Wrappers.GCF wrapper + = new(new SabreTools.Data.Models.GCF.File(), new MemoryStream(new byte[1024])); + + [Fact] + public void DetectFile_EmptyString_Null() + { + string file = string.Empty; + var detectable = new GCF(wrapper); + + string? actual = detectable.Detect(file, includeDebug: false); + Assert.Null(actual); + } + + [Fact] + public void DetectStream_EmptyStream_DefaultValue() + { + Stream? stream = new MemoryStream(); + string file = string.Empty; + var detectable = new GCF(wrapper); + + string? actual = detectable.Detect(stream, file, includeDebug: false); + Assert.Equal("AACS (Unknown Version)", actual); + } + } +} diff --git a/BinaryObjectScanner/FileType/GCF.cs b/BinaryObjectScanner/FileType/GCF.cs index e58a9204..f04a50fb 100644 --- a/BinaryObjectScanner/FileType/GCF.cs +++ b/BinaryObjectScanner/FileType/GCF.cs @@ -21,12 +21,13 @@ namespace BinaryObjectScanner.FileType // At the moment, all samples of GCF files on redump are unencrypted. Combined with being uncertain about // whether this is the best way to check whether the GCF is encrypted, this block will be left commented // out until further research is done. - /*bool encrypted = false; - if (_wrapper.Files != null && _wrapper.Files.Length > 0) - encrypted = _wrapper.Files[0].Encrypted; + // bool encrypted = false; + // if (_wrapper.Files != null && _wrapper.Files.Length > 0) + // encrypted = _wrapper.Files[0].Encrypted; + + // string encryptedString = encrypted ? "encrypted" : "unencrypted"; + // string returnString = $"{fileName} - {depotId} (v{manifestVersion}, {encryptedString})"; - string encryptedString = encrypted ? "encrypted" : "unencrypted"; - string returnString = $"{fileName} - {depotId} (v{manifestVersion}, {encryptedString})";*/ string returnString = $"{fileName} - {depotId} (v{manifestVersion})"; return returnString; }