Skip to content

Commit 0e71221

Browse files
committed
decode tests
1 parent 28f9820 commit 0e71221

7 files changed

Lines changed: 163 additions & 2 deletions

File tree

src/dsstats.decode/DecodeService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private void Error(DecodeParallelResult result)
336336
}
337337
}
338338

339-
private ReplayMetadata GetMetaData(Sc2Replay replay)
339+
public static ReplayMetadata GetMetaData(Sc2Replay replay)
340340
{
341341
List<ReplayMetadataPlayer> players = [];
342342

src/dsstats.ratings/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ static void Main(string[] args)
4343
{
4444
options.UseMySql(mySqlConnectionString, ServerVersion.AutoDetect(mySqlConnectionString), p =>
4545
{
46-
p.CommandTimeout(600);
46+
p.CommandTimeout(30);
4747
p.UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery);
4848
});
49+
options.EnableDetailedErrors();
50+
options.EnableSensitiveDataLogging();
4951
});
5052

5153
services.AddAutoMapper(typeof(AutoMapperProfile));

src/dsstats.ratings/RatingService.Combo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ private async Task ProduceComboRatings(bool recalc)
1919
var context = scope.ServiceProvider.GetRequiredService<ReplayContext>();
2020
var ratingSaveService = scope.ServiceProvider.GetRequiredService<IRatingsSaveService>();
2121
var comboRatings = scope.ServiceProvider.GetRequiredService<ComboRatings>();
22+
23+
context.Database.SetCommandTimeout(840);
2224

2325
await CleanupComboPreRatings(context);
2426

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using pax.dsstats.parser;
2+
using s2protocol.NET;
3+
4+
namespace dsstats.decode.tests;
5+
6+
[TestClass]
7+
public sealed class ParseTests
8+
{
9+
[TestMethod]
10+
public async Task CanDecodeReplay()
11+
{
12+
var path = "/data/ds/testreplays/Direct Strike TE (4545).SC2Replay";
13+
var decoder = new ReplayDecoder();
14+
var options = new ReplayDecoderOptions()
15+
{
16+
Initdata = true,
17+
Details = true,
18+
Metadata = true,
19+
TrackerEvents = true,
20+
};
21+
var sc2Replay = await decoder.DecodeAsync(path, options);
22+
Assert.IsNotNull(sc2Replay);
23+
var dsReplay = Parse.GetDsReplay(sc2Replay);
24+
Assert.IsNotNull(dsReplay);
25+
using var md5 = System.Security.Cryptography.MD5.Create();
26+
var replay = Parse.GetReplayDto(dsReplay, md5);
27+
Assert.IsNotNull(replay);
28+
}
29+
30+
[TestMethod]
31+
public async Task CanDecodeReplay2()
32+
{
33+
List<string> paths = ["/data/ds/testreplays/Direct Strike TE (4545).SC2Replay"];
34+
var decoder = new ReplayDecoder();
35+
var options = new ReplayDecoderOptions()
36+
{
37+
Initdata = true,
38+
Details = true,
39+
Metadata = true,
40+
TrackerEvents = true,
41+
};
42+
await foreach (var result in decoder.DecodeParallelWithErrorReport(paths, 1, options))
43+
{
44+
Assert.IsNotNull(result.Sc2Replay);
45+
var metaData = dsstats.decode.DecodeService.GetMetaData(result.Sc2Replay);
46+
var dsReplay = Parse.GetDsReplay(result.Sc2Replay);
47+
Assert.IsNotNull(dsReplay);
48+
using var md5 = System.Security.Cryptography.MD5.Create();
49+
var replay = Parse.GetReplayDto(dsReplay, md5);
50+
Assert.IsNotNull(replay);
51+
}
52+
}
53+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="MSTest" Version="4.0.1" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\..\dsstats.decode\dsstats.decode.csproj" />
16+
<ProjectReference Include="..\..\dsstats.maui\pax.dsstats.parser\pax.dsstats.parser.csproj" />
17+
<ProjectReference Include="..\..\dsstats.shared\dsstats.shared.csproj" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
22+
</ItemGroup>
23+
24+
</Project>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dsstats.shared", "..\..\dsstats.shared\dsstats.shared.csproj", "{3DFF95A8-63F3-4ADC-8233-825D8119E250}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pax.dsstats.parser", "..\..\dsstats.maui\pax.dsstats.parser\pax.dsstats.parser.csproj", "{8275C892-6B1D-4535-92A2-888DEEA52C00}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dsstats.decode.tests", "dsstats.decode.tests.csproj", "{390C7CD2-C11E-4116-9D27-818FB33ED0FE}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dsstats.decode", "..\..\dsstats.decode\dsstats.decode.csproj", "{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Debug|x64 = Debug|x64
18+
Debug|x86 = Debug|x86
19+
Release|Any CPU = Release|Any CPU
20+
Release|x64 = Release|x64
21+
Release|x86 = Release|x86
22+
EndGlobalSection
23+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
24+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Debug|x64.ActiveCfg = Debug|Any CPU
27+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Debug|x64.Build.0 = Debug|Any CPU
28+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Debug|x86.ActiveCfg = Debug|Any CPU
29+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Debug|x86.Build.0 = Debug|Any CPU
30+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Release|x64.ActiveCfg = Release|Any CPU
33+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Release|x64.Build.0 = Release|Any CPU
34+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Release|x86.ActiveCfg = Release|Any CPU
35+
{3DFF95A8-63F3-4ADC-8233-825D8119E250}.Release|x86.Build.0 = Release|Any CPU
36+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Debug|Any CPU.Build.0 = Debug|Any CPU
38+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Debug|x64.ActiveCfg = Debug|Any CPU
39+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Debug|x64.Build.0 = Debug|Any CPU
40+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Debug|x86.ActiveCfg = Debug|Any CPU
41+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Debug|x86.Build.0 = Debug|Any CPU
42+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Release|x64.ActiveCfg = Release|Any CPU
45+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Release|x64.Build.0 = Release|Any CPU
46+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Release|x86.ActiveCfg = Release|Any CPU
47+
{8275C892-6B1D-4535-92A2-888DEEA52C00}.Release|x86.Build.0 = Release|Any CPU
48+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
50+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Debug|x64.ActiveCfg = Debug|Any CPU
51+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Debug|x64.Build.0 = Debug|Any CPU
52+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Debug|x86.ActiveCfg = Debug|Any CPU
53+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Debug|x86.Build.0 = Debug|Any CPU
54+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
55+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Release|x64.ActiveCfg = Release|Any CPU
57+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Release|x64.Build.0 = Release|Any CPU
58+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Release|x86.ActiveCfg = Release|Any CPU
59+
{390C7CD2-C11E-4116-9D27-818FB33ED0FE}.Release|x86.Build.0 = Release|Any CPU
60+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Debug|Any CPU.Build.0 = Debug|Any CPU
62+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Debug|x64.ActiveCfg = Debug|Any CPU
63+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Debug|x64.Build.0 = Debug|Any CPU
64+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Debug|x86.ActiveCfg = Debug|Any CPU
65+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Debug|x86.Build.0 = Debug|Any CPU
66+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Release|Any CPU.ActiveCfg = Release|Any CPU
67+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Release|Any CPU.Build.0 = Release|Any CPU
68+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Release|x64.ActiveCfg = Release|Any CPU
69+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Release|x64.Build.0 = Release|Any CPU
70+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Release|x86.ActiveCfg = Release|Any CPU
71+
{C7C57907-67BD-9A5D-6CAC-F386EEB7B009}.Release|x86.Build.0 = Release|Any CPU
72+
EndGlobalSection
73+
GlobalSection(SolutionProperties) = preSolution
74+
HideSolutionNode = FALSE
75+
EndGlobalSection
76+
GlobalSection(ExtensibilityGlobals) = postSolution
77+
SolutionGuid = {F01C0578-C065-48AE-81A1-994AF5C2E043}
78+
EndGlobalSection
79+
EndGlobal

0 commit comments

Comments
 (0)