-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
43 changes: 41 additions & 2 deletions
43
tests/Modules/RoundRankingModule.Tests/Models/CheckpointsRepositoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,45 @@ | ||
namespace EvoSC.Modules.Official.RoundRankingModule.Tests.Models; | ||
using EvoSC.Common.Interfaces.Models.Enums; | ||
using EvoSC.Common.Models.Players; | ||
using EvoSC.Common.Util; | ||
using EvoSC.Modules.Official.RoundRankingModule.Models; | ||
|
||
namespace EvoSC.Modules.Official.RoundRankingModule.Tests.Models; | ||
|
||
public class CheckpointsRepositoryTests | ||
{ | ||
|
||
private CheckpointData CreateFakeCheckpointData(string accountId, int cpId, int time) | ||
{ | ||
return new CheckpointData | ||
{ | ||
Player = new OnlinePlayer { State = PlayerState.Playing, AccountId = accountId }, | ||
CheckpointId = cpId, | ||
Time = RaceTime.FromMilliseconds(time), | ||
IsFinish = false, | ||
IsDNF = cpId == -1 | ||
}; | ||
} | ||
|
||
[Fact] | ||
public void Sorts_Entries_Correctly() | ||
{ | ||
var cpRepository = new CheckpointsRepository | ||
{ | ||
["*fakeplayer1*"] = CreateFakeCheckpointData("*fakeplayer1*", 2, 500), // 2. | ||
["*fakeplayer2*"] = CreateFakeCheckpointData("*fakeplayer2*", 2, 250), // 1. | ||
["*fakeplayer3*"] = CreateFakeCheckpointData("*fakeplayer3*", 1, 1200), // 4. | ||
["*fakeplayer4*"] = CreateFakeCheckpointData("*fakeplayer4*", 1, 1000), // 3. | ||
["*fakeplayer5*"] = CreateFakeCheckpointData("*fakeplayer5*", 1, 1400), // 5. | ||
["*fakeplayer6*"] = CreateFakeCheckpointData("*fakeplayer6*", -1, 2000), // 6. | ||
["*fakeplayer7*"] = CreateFakeCheckpointData("*fakeplayer7*", -1, 2500), // 7. | ||
}; | ||
|
||
var sorted = cpRepository.GetSortedData(); | ||
Assert.Equal("*fakeplayer1*", sorted[1].Player.AccountId); | ||
Assert.Equal("*fakeplayer2*", sorted[0].Player.AccountId); | ||
Assert.Equal("*fakeplayer3*", sorted[3].Player.AccountId); | ||
Assert.Equal("*fakeplayer4*", sorted[2].Player.AccountId); | ||
Assert.Equal("*fakeplayer5*", sorted[4].Player.AccountId); | ||
Assert.Equal("*fakeplayer6*", sorted[5].Player.AccountId); | ||
Assert.Equal("*fakeplayer7*", sorted[6].Player.AccountId); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/Modules/RoundRankingModule.Tests/Models/PointsRepartitionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace EvoSC.Modules.Official.RoundRankingModule.Tests.Models; | ||
|
||
public class PointsRepartitionTests | ||
{ | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
tests/Modules/RoundRankingModule.Tests/Utils/RoundRankingUtilsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace EvoSC.Modules.Official.RoundRankingModule.Tests.Utils; | ||
|
||
public class RoundRankingUtilsTests | ||
{ | ||
|
||
} |