|
| 1 | +using Xunit; |
| 2 | + |
| 3 | +namespace EQ2Lexicon.ACTPlugin.Tests |
| 4 | +{ |
| 5 | + /// <summary> |
| 6 | + /// Pins the EQ2 log-path → server-name parser. Tests use forward |
| 7 | + /// slashes in path inputs because Path.GetDirectoryName / |
| 8 | + /// Path.GetFileName accept both separators on Windows (the only |
| 9 | + /// platform ACT runs on); keeps test strings readable. |
| 10 | + /// </summary> |
| 11 | + public class LogPathParserTests |
| 12 | + { |
| 13 | + [Theory] |
| 14 | + [InlineData(@"C:\Program Files\Sony\EverQuest II\logs\Varsoon\eq2log_Kayleigh.txt", "Varsoon")] |
| 15 | + [InlineData(@"C:\Program Files\Sony\EverQuest II\logs\Kaladim\eq2log_Kayleigh.txt", "Kaladim")] |
| 16 | + [InlineData(@"C:\Program Files\Sony\EverQuest II\logs\Butcherblock\eq2log_SomeAlt.txt", "Butcherblock")] |
| 17 | + [InlineData(@"D:\Games\EQ2\logs\Nagafen\eq2log_PvP.txt", "Nagafen")] |
| 18 | + public void ParseServerName_HappyPath(string path, string expected) |
| 19 | + { |
| 20 | + Assert.Equal(expected, LogPathParser.ParseServerName(path)); |
| 21 | + } |
| 22 | + |
| 23 | + [Fact] |
| 24 | + public void ParseServerName_PassesMultiWordServersThrough() |
| 25 | + { |
| 26 | + // EQ2 wiki / fan sites don't conclusively document whether |
| 27 | + // "Antonia Bayle" appears with the space in the directory |
| 28 | + // name or stripped. We pass the directory name through |
| 29 | + // unmodified — Daybreak's Census API accepts world names |
| 30 | + // with spaces, so either form will work if the directory |
| 31 | + // matches. Pinning the behaviour here means a future user |
| 32 | + // report ("AB doesn't work") points the finger at the |
| 33 | + // game's filesystem choice, not at our parser. |
| 34 | + Assert.Equal("Antonia Bayle", |
| 35 | + LogPathParser.ParseServerName(@"C:\EQ2\logs\Antonia Bayle\eq2log_Char.txt")); |
| 36 | + } |
| 37 | + |
| 38 | + [Fact] |
| 39 | + public void ParseServerName_ReturnsEmptyForLegacyGenericLog() |
| 40 | + { |
| 41 | + // User never ran /log in-game — EQ2 wrote to the generic |
| 42 | + // logs/eq2log.txt path. Parent directory is literally |
| 43 | + // "logs", which is not a server name. Server has to fall |
| 44 | + // back to its EQ2_WORLD default. |
| 45 | + Assert.Equal("", |
| 46 | + LogPathParser.ParseServerName(@"C:\Program Files\Sony\EverQuest II\logs\eq2log.txt")); |
| 47 | + } |
| 48 | + |
| 49 | + [Fact] |
| 50 | + public void ParseServerName_CaseInsensitiveLogsDirectoryCheck() |
| 51 | + { |
| 52 | + // Some EQ2 installs may use lowercase, some uppercase. |
| 53 | + // The "logs" sentinel comparison must be case-insensitive. |
| 54 | + Assert.Equal("", |
| 55 | + LogPathParser.ParseServerName(@"C:\EQ2\Logs\eq2log.txt")); |
| 56 | + Assert.Equal("", |
| 57 | + LogPathParser.ParseServerName(@"C:\EQ2\LOGS\eq2log.txt")); |
| 58 | + } |
| 59 | + |
| 60 | + [Theory] |
| 61 | + [InlineData(null)] |
| 62 | + [InlineData("")] |
| 63 | + [InlineData(" ")] |
| 64 | + public void ParseServerName_ReturnsEmptyForMissingPath(string? path) |
| 65 | + { |
| 66 | + Assert.Equal("", LogPathParser.ParseServerName(path)); |
| 67 | + } |
| 68 | + |
| 69 | + [Fact] |
| 70 | + public void ParseServerName_ReturnsEmptyForBareFilename() |
| 71 | + { |
| 72 | + // No directory component at all → nothing to extract. |
| 73 | + Assert.Equal("", LogPathParser.ParseServerName("eq2log_Kayleigh.txt")); |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments