EDBGS/EDPlayerJournalTests/FileHeaderTest.cs

55 lines
2.0 KiB
C#
Raw Permalink Normal View History

using EDPlayerJournal.Entries;
namespace EDPlayerJournalTests;
[TestClass]
public class FileHeaderTest {
[TestMethod]
public void OdysseyFileHeader() {
string fileheader = /*lang=json,strict*/ """{ "timestamp":"2022-11-21T15:04:36Z", "event":"Fileheader", "part":1, "language":"English/UK", "Odyssey":true, "gameversion":"4.0.0.1450", "build":"r286858/r0 " }""";
Entry? entry = Entry.Parse(fileheader);
Assert.IsNotNull(entry);
Assert.IsInstanceOfType(entry, typeof(FileHeaderEntry));
FileHeaderEntry? header = entry as FileHeaderEntry;
Assert.IsNotNull(header);
Assert.AreEqual(header.Part, 1UL);
Assert.AreEqual(header.Language, "English/UK");
Assert.AreEqual(header.Odyssey, true);
Assert.AreEqual(header.GameVersion, "4.0.0.1450");
2022-11-28 13:32:54 +01:00
Assert.AreEqual(header.IsLegacy, false);
Assert.AreEqual(header.IsLive, true);
// Someone at FDev messed up string building there.
Assert.AreEqual(header.Build, "r286858/r0 ");
}
[TestMethod]
public void LegacyFileHeader() {
// This is the oldest file header I could find.
string fileheader = /*lang=json,strict*/ """{ "timestamp":"2020-01-02T23:45:23Z", "event":"Fileheader", "part":1, "language":"English\\UK", "gameversion":"3.5.3.400 EDH", "build":"r213094/r0 " }""";
Entry? entry = Entry.Parse(fileheader);
Assert.IsNotNull(entry);
Assert.IsInstanceOfType(entry, typeof(FileHeaderEntry));
FileHeaderEntry? header = entry as FileHeaderEntry;
Assert.IsNotNull(header);
Assert.AreEqual(header.Part, 1UL);
// At some point they switche to a forward slash. Curious.
Assert.AreEqual(header.Language, """English\UK""");
Assert.AreEqual(header.Odyssey, false);
Assert.AreEqual(header.GameVersion, "3.5.3.400 EDH");
2022-11-28 13:32:54 +01:00
Assert.AreEqual(header.IsLegacy, true);
Assert.AreEqual(header.IsLive, false);
// ~73k commits in two years. Not bad.
Assert.AreEqual(header.Build, "r213094/r0 ");
}
}