Skip to content

Commit 3155bba

Browse files
committed
♻️ refactor journal event handling
semver: chore
1 parent 19ea0e7 commit 3155bba

14 files changed

Lines changed: 907 additions & 144 deletions

File tree

Console/Program.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
using EliteApi;
2+
using EliteAPI.Journals;
23
using EliteAPI.Json;
34

4-
var api = new EliteDangerousApi();
5-
api.OnJournalEvent(e =>
6-
{
7-
var paths = JsonUtils.FlattenJson(e.json).Select(p => p.WithPath($"EliteAPI.{e.eventName}.{p.Path}")).ToList();
8-
9-
foreach (var path in paths)
10-
Console.WriteLine($"{path.Path}: {path.Value} ({path.Type})");
5+
var json = await File.ReadAllTextAsync("./EliteAPI.Tests/TestFiles/Status/StatusCombat.json");
6+
var paths = JournalUtils.ToPaths(json);
117

12-
Console.WriteLine($"((EliteAPI.{e.eventName}))");
13-
});
14-
15-
Thread.Sleep(-1);
8+
foreach (var path in paths)
9+
{
10+
Console.WriteLine($"{path.Path}: {path.Value} ({path.Type})");
11+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using EliteAPI.Journals;
2+
using EliteAPI.Json;
3+
using FluentAssertions;
4+
5+
namespace EliteAPI.Tests;
6+
7+
public class EventTriggeringTests
8+
{
9+
[Test]
10+
public async Task StatusInCombat()
11+
{
12+
// var json = await File.ReadAllTextAsync("../../../TestFiles/Status/StatusCombat.json");
13+
// var paths = JournalUtils.ToPaths(json);
14+
15+
// JsonPath[] expectedPaths = [
16+
// new JsonPath("EliteAPI.event", "Status", JsonType.String),
17+
// new JsonPath("EliteAPI.Status", 262144, JsonType.Number),
18+
// ];
19+
20+
// foreach (var expectedPath in expectedPaths)
21+
// {
22+
// paths.Should().ContainEquivalentOf(expectedPath);
23+
// }
24+
}
25+
26+
// [Test]
27+
// [MethodDataSource(nameof(GetStatusFiles))]
28+
// public async Task StatusFile(FileInfo file)
29+
// {
30+
// var json = await File.ReadAllTextAsync(file.FullName);
31+
// await Assert.That(json).IsEqualTo("poop");
32+
// }
33+
}

0 commit comments

Comments
 (0)