Skip to content

Commit 883fe0c

Browse files
committed
✅ update tests to use xunit
semver: chore
1 parent 4b67709 commit 883fe0c

11 files changed

Lines changed: 2348 additions & 99 deletions

EliteAPI.Tests/BindingTests.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ namespace EliteAPI.Tests.Bindings;
66
public class BindingParserTests
77
{
88

9-
[Test]
9+
[Fact]
1010
public void Parse_Sample_File()
1111
{
12-
string xml = File.ReadAllText("test.binds");
12+
string xml = File.ReadAllText("Bindings/test.binds");
1313

1414
var content = BindingParser.Parse(xml);
1515

1616
content.Should().NotBeNull();
1717
}
1818

19-
[Test]
19+
[Fact]
2020
public void Parse_Should_Read_Simple_Primary_Keyboard_Bindings()
2121
{
2222
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -53,7 +53,7 @@ public void Parse_Should_Read_Simple_Primary_Keyboard_Bindings()
5353
yawRight.Secondary.HasValue.Should().BeFalse();
5454
}
5555

56-
[Test]
56+
[Fact]
5757
public void Parse_Should_Treat_NoDevice_EmptyKey_As_Unbound()
5858
{
5959
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -85,7 +85,7 @@ public void Parse_Should_Treat_NoDevice_EmptyKey_As_Unbound()
8585
}
8686
}
8787

88-
[Test]
88+
[Fact]
8989
public void Parse_Should_Map_Binding_Element_To_Primary_And_Read_Inverted_And_Deadzone()
9090
{
9191
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -114,7 +114,7 @@ public void Parse_Should_Map_Binding_Element_To_Primary_And_Read_Inverted_And_De
114114
control.Deadzone.Should().Be(0.25f);
115115
}
116116

117-
[Test]
117+
[Fact]
118118
public void Parse_Should_Handle_All_ToggleOn_Variants()
119119
{
120120
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -161,7 +161,7 @@ public void Parse_Should_Handle_All_ToggleOn_Variants()
161161
controls["MouseReset"].IsToggle.Should().BeNull();
162162
}
163163

164-
[Test]
164+
[Fact]
165165
public void Parse_Should_Read_Modifiers_On_Primary_And_Secondary()
166166
{
167167
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -227,7 +227,7 @@ public void Parse_Should_Read_Modifiers_On_Primary_And_Secondary()
227227
secondReverseMod.Key.Should().Be("Key_RightShift");
228228
}
229229

230-
[Test]
230+
[Fact]
231231
public void Parse_Should_Ignore_Hold_Child_And_Still_Parse_Binding_And_Toggle()
232232
{
233233
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -257,7 +257,7 @@ public void Parse_Should_Ignore_Hold_Child_And_Still_Parse_Binding_And_Toggle()
257257
control.IsToggle.Should().BeFalse(); // Value=""0""
258258
}
259259

260-
[Test]
260+
[Fact]
261261
public void Parse_Should_Treat_Key_Attribute_Case_Insensitive()
262262
{
263263
// Based on ToggleVanityCamera in HCS, but with a meaningful secondary key
@@ -282,7 +282,7 @@ public void Parse_Should_Treat_Key_Attribute_Case_Insensitive()
282282
control.Secondary!.Value.Key.Should().Be("Key_F12");
283283
}
284284

285-
[Test]
285+
[Fact]
286286
public void Parse_Should_Handle_Float_Deadzone_Formats()
287287
{
288288
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -312,7 +312,7 @@ public void Parse_Should_Handle_Float_Deadzone_Formats()
312312
controls["VerticalThrustRaw"].Deadzone.Should().Be(7.0f);
313313
}
314314

315-
[Test]
315+
[Fact]
316316
public void Parse_Should_Ignore_Value_Only_Elements_And_Only_Return_Controls_With_Bindings()
317317
{
318318
const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
@@ -335,4 +335,17 @@ public void Parse_Should_Ignore_Value_Only_Elements_And_Only_Return_Controls_Wit
335335
controls.Select(c => c.Name).Should().NotContain("MouseSensitivity");
336336
controls.Select(c => c.Name).Should().NotContain("MouseGUI");
337337
}
338+
339+
[Fact]
340+
public void Parse_HCS_Bindings()
341+
{
342+
string xml = File.ReadAllText("TestFiles/Bindings/HCS Custom.4.2.binds");
343+
344+
var content = BindingParser.Parse(xml);
345+
346+
content.Should().NotBeNull();
347+
content.Should().Contain(c => c.Name == "CycleFireGroupPrevious");
348+
var control = content.Single(c => c.Name == "CycleFireGroupPrevious");
349+
control.KeyCode.Should().Be("[160][72]"); // LeftShift + H
350+
}
338351
}

EliteAPI.Tests/EliteAPI.Tests.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<IsTestProject>true</IsTestProject>
78
</PropertyGroup>
89

910
<ItemGroup>
10-
<PackageReference Include="TUnit" Version="1.7.20" />
11+
<PackageReference Include="xunit" Version="2.9.2" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
<PrivateAssets>all</PrivateAssets>
15+
</PackageReference>
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1117
<PackageReference Include="FluentAssertions" Version="8.8.0" />
1218
</ItemGroup>
1319

@@ -16,7 +22,10 @@
1622
</ItemGroup>
1723

1824
<ItemGroup>
19-
<None Update="test.binds">
25+
<None Update="TestFiles\Bindings\HCS Custom.4.2.binds">
26+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
27+
</None>
28+
<None Update="TestFiles\Bindings\test.binds">
2029
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2130
</None>
2231
</ItemGroup>

EliteAPI.Tests/EventTriggeringTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace EliteAPI.Tests;
22

33
public class EventTriggeringTests
44
{
5-
[Test]
5+
[Fact]
66
public async Task StatusInCombat()
77
{
88
// var json = await File.ReadAllTextAsync("../../../TestFiles/Status/StatusCombat.json");

EliteAPI.Tests/FileUtilsTests.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@
77

88
namespace EliteAPI.Tests;
99

10-
public class FileUtilsTests
10+
public class FileUtilsTests : IDisposable
1111
{
1212
private string _testDir = null!;
1313

14-
[Before(Test)]
15-
public void Setup()
14+
public FileUtilsTests()
1615
{
1716
_testDir = Path.Combine(Path.GetTempPath(), $"EliteAPI.Tests.{Guid.NewGuid()}");
1817
Directory.CreateDirectory(_testDir);
1918
}
2019

21-
[After(Test)]
22-
public void Cleanup()
20+
public void Dispose()
2321
{
2422
if (Directory.Exists(_testDir))
2523
Directory.Delete(_testDir, true);
2624
}
2725

28-
[Test]
26+
[Fact]
2927
public void WriteWithRetry_WritesContentToFile()
3028
{
3129
var path = Path.Combine(_testDir, "test.txt");
@@ -37,7 +35,7 @@ public void WriteWithRetry_WritesContentToFile()
3735
File.ReadAllText(path).Should().Be(content);
3836
}
3937

40-
[Test]
38+
[Fact]
4139
public void WriteWithRetry_OverwritesExistingFile()
4240
{
4341
var path = Path.Combine(_testDir, "test.txt");
@@ -48,7 +46,7 @@ public void WriteWithRetry_OverwritesExistingFile()
4846
File.ReadAllText(path).Should().Be("New content");
4947
}
5048

51-
[Test]
49+
[Fact]
5250
public void WriteWithRetry_AllowsConcurrentReads()
5351
{
5452
var path = Path.Combine(_testDir, "test.txt");
@@ -63,7 +61,7 @@ public void WriteWithRetry_AllowsConcurrentReads()
6361
writeAction.Should().NotThrow();
6462
}
6563

66-
[Test]
64+
[Fact]
6765
public async Task WriteWithRetry_RetriesOnTemporaryLock()
6866
{
6967
var path = Path.Combine(_testDir, "test.txt");
@@ -96,7 +94,7 @@ public async Task WriteWithRetry_RetriesOnTemporaryLock()
9694
File.ReadAllText(path).Should().Be("After retry");
9795
}
9896

99-
[Test]
97+
[Fact]
10098
public void WriteWithRetry_ThrowsAfterMaxRetries()
10199
{
102100
var path = Path.Combine(_testDir, "test.txt");
@@ -110,7 +108,7 @@ public void WriteWithRetry_ThrowsAfterMaxRetries()
110108
writeAction.Should().Throw<IOException>();
111109
}
112110

113-
[Test]
111+
[Fact]
114112
public async Task WriteWithRetry_HandlesMultipleConcurrentWriters()
115113
{
116114
var path = Path.Combine(_testDir, "test.txt");
@@ -131,7 +129,7 @@ public async Task WriteWithRetry_HandlesMultipleConcurrentWriters()
131129
File.ReadAllText(path).Should().StartWith("Content ");
132130
}
133131

134-
[Test]
132+
[Fact]
135133
public void AppendWithRetry_AppendsContentToFile()
136134
{
137135
var path = Path.Combine(_testDir, "test.txt");
@@ -142,7 +140,7 @@ public void AppendWithRetry_AppendsContentToFile()
142140
File.ReadAllText(path).Should().Be("Line 1\nLine 2\n");
143141
}
144142

145-
[Test]
143+
[Fact]
146144
public void AppendWithRetry_CreatesFileIfNotExists()
147145
{
148146
var path = Path.Combine(_testDir, "new.txt");
@@ -153,7 +151,7 @@ public void AppendWithRetry_CreatesFileIfNotExists()
153151
File.ReadAllText(path).Should().Be("First line");
154152
}
155153

156-
[Test]
154+
[Fact]
157155
public async Task AppendWithRetry_HandlesMultipleConcurrentAppends()
158156
{
159157
var path = Path.Combine(_testDir, "test.txt");

0 commit comments

Comments
 (0)