@@ -11,7 +11,68 @@ public class DummyCalculatorServiceTest : CalculatorServiceTest<DummyScore, Dumm
11
11
[ InlineData ( 15 , 1500 , "test 1" , 150 ) ]
12
12
[ InlineData ( 10 , 1000 , "test 2" , 100 ) ]
13
13
public void Test ( double expectedDifficultyTotal , double expectedPerformanceTotal , string beatmapId , int mods )
14
- => TestGetCalculationReturnsCorrectValues ( expectedDifficultyTotal , expectedPerformanceTotal , new DummyScore { BeatmapId = beatmapId , Mods = mods } ) ;
14
+ => TestGetCalculationReturnsCorrectValues ( expectedDifficultyTotal , expectedPerformanceTotal , new DummyScore { BeatmapId = beatmapId , Mods = mods , Points = 100 } ) ;
15
+
16
+ [ Fact ]
17
+ public async Task TestGetCalculationBatchReturnsCorrectValuesInOrder ( )
18
+ {
19
+ // values are intentionally in a random order to ensure unique beatmap grouping doesnt break return ordering
20
+ var scores = new [ ]
21
+ {
22
+ new DummyScore { BeatmapId = "test 1" , Mods = 200 , Points = 200 } , // 3
23
+ new DummyScore { BeatmapId = "test 2" , Mods = 300 , Points = 100 } , // 4
24
+ new DummyScore { BeatmapId = "test 2" , Mods = 300 , Points = 200 } , // 5
25
+ new DummyScore { BeatmapId = "test 3" , Mods = 500 , Points = 200 } , // 9
26
+ new DummyScore { BeatmapId = "test 2" , Mods = 400 , Points = 200 } , // 7
27
+ new DummyScore { BeatmapId = "test 1" , Mods = 200 , Points = 100 } , // 2
28
+ new DummyScore { BeatmapId = "test 3" , Mods = 600 , Points = 100 } , // 10
29
+ new DummyScore { BeatmapId = "test 2" , Mods = 400 , Points = 100 } , // 6
30
+ new DummyScore { BeatmapId = "test 3" , Mods = 500 , Points = 100 } , // 8
31
+ new DummyScore { BeatmapId = "test 1" , Mods = 100 , Points = 200 } , // 1
32
+ new DummyScore { BeatmapId = "test 3" , Mods = 600 , Points = 200 } , // 11
33
+ new DummyScore { BeatmapId = "test 1" , Mods = 100 , Points = 100 } , // 0
34
+ } ;
35
+
36
+ var calculations = ( await CalculatorService . GetCalculationBatch ( scores ) ) . ToArray ( ) ;
37
+
38
+ Assert . Equal ( 12 , calculations . Length ) ;
39
+
40
+ Assert . Equal ( 20 , calculations [ 0 ] . Difficulty . Total ) ; // 3
41
+ Assert . Equal ( 4000 , calculations [ 0 ] . Performance . Total ) ;
42
+
43
+ Assert . Equal ( 30 , calculations [ 1 ] . Difficulty . Total ) ; // 4
44
+ Assert . Equal ( 3000 , calculations [ 1 ] . Performance . Total ) ;
45
+
46
+ Assert . Equal ( 30 , calculations [ 2 ] . Difficulty . Total ) ; // 5
47
+ Assert . Equal ( 6000 , calculations [ 2 ] . Performance . Total ) ;
48
+
49
+ Assert . Equal ( 50 , calculations [ 3 ] . Difficulty . Total ) ; // 9
50
+ Assert . Equal ( 10000 , calculations [ 3 ] . Performance . Total ) ;
51
+
52
+ Assert . Equal ( 40 , calculations [ 4 ] . Difficulty . Total ) ; // 7
53
+ Assert . Equal ( 8000 , calculations [ 4 ] . Performance . Total ) ;
54
+
55
+ Assert . Equal ( 20 , calculations [ 5 ] . Difficulty . Total ) ; // 2
56
+ Assert . Equal ( 2000 , calculations [ 5 ] . Performance . Total ) ;
57
+
58
+ Assert . Equal ( 60 , calculations [ 6 ] . Difficulty . Total ) ; // 10
59
+ Assert . Equal ( 6000 , calculations [ 6 ] . Performance . Total ) ;
60
+
61
+ Assert . Equal ( 40 , calculations [ 7 ] . Difficulty . Total ) ; // 6
62
+ Assert . Equal ( 4000 , calculations [ 7 ] . Performance . Total ) ;
63
+
64
+ Assert . Equal ( 50 , calculations [ 8 ] . Difficulty . Total ) ; // 8
65
+ Assert . Equal ( 5000 , calculations [ 8 ] . Performance . Total ) ;
66
+
67
+ Assert . Equal ( 10 , calculations [ 9 ] . Difficulty . Total ) ; // 1
68
+ Assert . Equal ( 2000 , calculations [ 9 ] . Performance . Total ) ;
69
+
70
+ Assert . Equal ( 60 , calculations [ 10 ] . Difficulty . Total ) ; // 11
71
+ Assert . Equal ( 12000 , calculations [ 10 ] . Performance . Total ) ;
72
+
73
+ Assert . Equal ( 10 , calculations [ 11 ] . Difficulty . Total ) ; // 0
74
+ Assert . Equal ( 1000 , calculations [ 11 ] . Performance . Total ) ;
75
+ }
15
76
}
16
77
17
78
/// <summary>
@@ -29,17 +90,17 @@ public class DummyCalculatorService(ICache cache) : CalculatorService<DummyScore
29
90
CalculatorUrl = $ "not.a.real.url"
30
91
} ;
31
92
32
- protected override ( object , string ) CalculateDifficultyAttributes ( DummyScore score )
93
+ protected override ( object , string ) CalculateDifficultyAttributes ( string beatmapId , int mods )
33
94
{
34
- var difficulty = score . Mods / 10.0 ;
95
+ var difficulty = mods / 10.0 ;
35
96
return ( difficulty , difficulty . ToString ( ) ) ;
36
97
}
37
98
38
99
protected override DummyCalculation CalculatePerformance ( DummyScore score , object difficultyAttributes ) =>
39
100
new ( )
40
101
{
41
102
Difficulty = new DummyDifficulty ( ) { Total = ( double ) difficultyAttributes } ,
42
- Performance = new DummyPerformance ( ) { Total = ( double ) difficultyAttributes * 100 }
103
+ Performance = new DummyPerformance ( ) { Total = ( double ) difficultyAttributes * score . Points }
43
104
} ;
44
105
45
106
protected override object DeserialiseDifficultyAttributes ( string difficultyAttributesJson ) =>
@@ -49,7 +110,10 @@ protected override Task EnsureBeatmap(string beatmapId) =>
49
110
Task . FromResult ( true ) ;
50
111
}
51
112
52
- public record DummyScore : Score { }
113
+ public record DummyScore : Score
114
+ {
115
+ public int Points { get ; init ; }
116
+ }
53
117
public record DummyDifficulty : Difficulty { }
54
118
public record DummyPerformance : Performance { }
55
119
public record DummyCalculation : Calculation < DummyDifficulty , DummyPerformance > { }
0 commit comments