Apply R# clean-up for reliability (#877)
* Apply R# clean-up for reliability - Migrate to NUnit4 Assert.That - Update dependencise versions - Fix LangVersion to 9.0 (until net core migration) - Reformat code - Apply 'var' style (easier for refactoring) - Remove redundant parentheses - Add braces on every condition blocks (1 line) - Uses new null checking patterns - Uses AutoProperties when possible - Uses string scalar type instead of class - Clean usings - Add .orig files in git ignore - Rename some properties to respect defined conventions and US format definition - ID -> Id - BPM -> Bpm - Finish -> End * Update R# settings according to the clean-up made
This commit is contained in:
1 parent
b9b0f7c8df
commit
6ffa63b923
236 files changed
+14194
-7278
No files matched your search
@@ -20,9 +20,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Reporting;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.PartyModes.Challenge;
|
||||
|
||||
namespace Tests.PartyModeChallenge
|
||||
@@ -31,20 +29,19 @@ namespace Tests.PartyModeChallenge
|
||||
public class CPartyModeChallangeTest
|
||||
{
|
||||
#region Tests
|
||||
|
||||
[Test]
|
||||
public void TestRoundBoundaries()
|
||||
{
|
||||
// ReSharper disable ObjectCreationAsStatement
|
||||
new CChallengeRounds(1, 1, 1); // Should succeed
|
||||
// ReSharper restore ObjectCreationAsStatement
|
||||
for (int inv = -1; inv <= 0; inv++)
|
||||
for (var inv = -1; inv <= 0; inv++)
|
||||
{
|
||||
int invL = inv;
|
||||
var invL = inv;
|
||||
// ReSharper disable ObjectCreationAsStatement
|
||||
Assert.Throws<ArgumentException>(() => new CChallengeRounds(invL, 1, 1));
|
||||
Assert.Throws<ArgumentException>(() => new CChallengeRounds(1, invL, 1));
|
||||
Assert.Throws<ArgumentException>(() => new CChallengeRounds(1, 1, invL));
|
||||
Assert.Throws<ArgumentException>(new Action(() => new CChallengeRounds(invL, 1, 1)));
|
||||
Assert.Throws<ArgumentException>(new Action(() => new CChallengeRounds(1, invL, 1)));
|
||||
Assert.Throws<ArgumentException>(new Action(() => new CChallengeRounds(1, 1, invL)));
|
||||
// ReSharper restore ObjectCreationAsStatement
|
||||
}
|
||||
}
|
||||
@@ -54,36 +51,38 @@ namespace Tests.PartyModeChallenge
|
||||
{
|
||||
CBase.Game = new CBGame();
|
||||
|
||||
int roundFactor = (numPlayer % numMic == 0) ? numPlayer / numMic : numPlayer;
|
||||
for (int numRounds = roundFactor; numRounds <= 100 && numRounds <= roundFactor * 5; numRounds += roundFactor)
|
||||
var roundFactor = numPlayer % numMic == 0 ? numPlayer / numMic : numPlayer;
|
||||
for (var numRounds = roundFactor; numRounds <= 100 && numRounds <= roundFactor * 5; numRounds += roundFactor)
|
||||
{
|
||||
CChallengeRounds rounds = new CChallengeRounds(numRounds, numPlayer, numMic);
|
||||
Assert.IsTrue(rounds.Count >= numRounds);
|
||||
var rounds = new CChallengeRounds(numRounds, numPlayer, numMic);
|
||||
Assert.That(rounds.Count >= numRounds, Is.True);
|
||||
_CheckRounds(rounds, numPlayer);
|
||||
Assert.That(rounds.Count, Is.GreaterThanOrEqualTo(numRounds),
|
||||
Assert.That(rounds.Count, Is.GreaterThanOrEqualTo(numRounds),
|
||||
$"Number of rounds should be >= {numRounds}, is {rounds.Count} for {numPlayer}/{numMic}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper methods
|
||||
private static void _CheckRounds(CChallengeRounds rounds, int numPlayer)
|
||||
{
|
||||
List<int> numSongs = new List<int>(numPlayer);
|
||||
for (int i = 0; i < numPlayer; i++)
|
||||
numSongs.Add(0);
|
||||
for (int i = 0; i < rounds.Count; i++)
|
||||
var numSongs = new List<int>(numPlayer);
|
||||
for (var i = 0; i < numPlayer; i++)
|
||||
{
|
||||
foreach (int player in rounds[i].Players)
|
||||
numSongs.Add(0);
|
||||
}
|
||||
|
||||
for (var i = 0; i < rounds.Count; i++)
|
||||
{
|
||||
foreach (var player in rounds[i].Players)
|
||||
{
|
||||
Assert.IsTrue(player >= 0 && player < numPlayer);
|
||||
Assert.That(player >= 0 && player < numPlayer, Is.True);
|
||||
numSongs[player]++;
|
||||
}
|
||||
}
|
||||
Assert.IsTrue(numSongs.Min() == numSongs.Max(), "Some players have more songs than others");
|
||||
}
|
||||
|
||||
Assert.That(numSongs.Min() == numSongs.Max(), Is.True, "Some players have more songs than others");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user