-
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
2 changed files
with
45 additions
and
17 deletions.
There are no files selected for viewing
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
46 changes: 44 additions & 2 deletions
46
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 |
---|---|---|
@@ -1,6 +1,48 @@ | ||
namespace EvoSC.Modules.Official.RoundRankingModule.Tests.Models; | ||
using EvoSC.Modules.Official.RoundRankingModule.Models; | ||
|
||
namespace EvoSC.Modules.Official.RoundRankingModule.Tests.Models; | ||
|
||
public class PointsRepartitionTests | ||
{ | ||
|
||
[Theory] | ||
[InlineData("1,2,3,4,5,6,7", new[] { 1, 2, 3, 4, 5, 6, 7 })] | ||
[InlineData("10,6,4,3,2,1", new[] { 10, 6, 4, 3, 2, 1 })] | ||
[InlineData("0, 0, 1, 2, -4, -5", new[] { 0, 0, 1, 2, -4, -5 })] | ||
public void Sets_Points_From_String(string pointsRepartition, int[] expectedPoints) | ||
{ | ||
var pr = new PointsRepartition(); | ||
pr.Update(pointsRepartition); | ||
|
||
Assert.Equal(expectedPoints, pr.ToArray()); | ||
} | ||
|
||
[Fact] | ||
public void Initializes_PointsRepartition_With_Default() | ||
{ | ||
var expected = PointsRepartition.DefaultValue.Split(',').Select(int.Parse).ToList(); | ||
|
||
Assert.Equal(expected, new PointsRepartition()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("10,6,4,3,2,1", 1, 10)] | ||
[InlineData("10,6,4,3,2,1", 2, 6)] | ||
[InlineData("10,6,4,3,2,1", 3, 4)] | ||
[InlineData("10,6,4,3,2,1", 4, 3)] | ||
[InlineData("10,6,4,3,2,1", 5, 2)] | ||
[InlineData("10,6,4,3,2,1", 6, 1)] | ||
[InlineData("10,6,4,3,2,1", 7, 1)] | ||
[InlineData("-1,-2,0,7,3", 1, -1)] | ||
[InlineData("-1,-2,0,7,3", 2, -2)] | ||
[InlineData("-1,-2,0,7,3", 3, 0)] | ||
[InlineData("-1,-2,0,7,3", 4, 7)] | ||
[InlineData("-1,-2,0,7,3", 5, 3)] | ||
[InlineData("-1,-2,0,7,3", 6, 3)] | ||
public void Gets_Gained_Points_Correctly(string pointsRepartition, int rank, int expectedGainedPoints) | ||
{ | ||
var pr = new PointsRepartition(); | ||
pr.Update(pointsRepartition); | ||
|
||
Assert.Equal(expectedGainedPoints, pr.GetGainedPoints(rank)); | ||
} | ||
} |