Skip to content

Commit 95f152c

Browse files
committed
Add GCF tests
1 parent ff02fdb commit 95f152c

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.IO;
2+
using BinaryObjectScanner.FileType;
3+
using Xunit;
4+
5+
namespace BinaryObjectScanner.Test.FileType
6+
{
7+
public class GCFTests
8+
{
9+
private static readonly SabreTools.Serialization.Wrappers.GCF wrapper
10+
= new(new SabreTools.Data.Models.GCF.File(), new MemoryStream(new byte[1024]));
11+
12+
[Fact]
13+
public void DetectFile_EmptyString_Null()
14+
{
15+
string file = string.Empty;
16+
var detectable = new GCF(wrapper);
17+
18+
string? actual = detectable.Detect(file, includeDebug: false);
19+
Assert.Null(actual);
20+
}
21+
22+
[Fact]
23+
public void DetectStream_EmptyStream_DefaultValue()
24+
{
25+
Stream? stream = new MemoryStream();
26+
string file = string.Empty;
27+
var detectable = new GCF(wrapper);
28+
29+
string? actual = detectable.Detect(stream, file, includeDebug: false);
30+
Assert.Equal("AACS (Unknown Version)", actual);
31+
}
32+
}
33+
}

BinaryObjectScanner/FileType/GCF.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ public GCF(SabreTools.Serialization.Wrappers.GCF wrapper) : base(wrapper) { }
2121
// At the moment, all samples of GCF files on redump are unencrypted. Combined with being uncertain about
2222
// whether this is the best way to check whether the GCF is encrypted, this block will be left commented
2323
// out until further research is done.
24-
/*bool encrypted = false;
25-
if (_wrapper.Files != null && _wrapper.Files.Length > 0)
26-
encrypted = _wrapper.Files[0].Encrypted;
24+
// bool encrypted = false;
25+
// if (_wrapper.Files != null && _wrapper.Files.Length > 0)
26+
// encrypted = _wrapper.Files[0].Encrypted;
27+
28+
// string encryptedString = encrypted ? "encrypted" : "unencrypted";
29+
// string returnString = $"{fileName} - {depotId} (v{manifestVersion}, {encryptedString})";
2730

28-
string encryptedString = encrypted ? "encrypted" : "unencrypted";
29-
string returnString = $"{fileName} - {depotId} (v{manifestVersion}, {encryptedString})";*/
3031
string returnString = $"{fileName} - {depotId} (v{manifestVersion})";
3132
return returnString;
3233
}

0 commit comments

Comments
 (0)