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:
Quentin Bray authored and GitHub committed 2026-06-22 19:52:06 +02:00
1 parent b9b0f7c8df
commit 6ffa63b923
236 files changed
+14194 -7278

No files matched your search

@@ -27,72 +27,82 @@ namespace Tests.VocaluxeLib.Utils.Combinatorics
public class CCombinationsTest
{
#region Tests
[Test]
public void TestCount()
{
Assert.AreEqual(4, CCombinations<int>.Count(4, 3));
Assert.AreEqual(6, CCombinations<int>.Count(4, 2));
Assert.AreEqual(66, CCombinations<int>.Count(12, 2));
Assert.That(CCombinations<int>.Count(4, 3), Is.EqualTo(4));
Assert.That(CCombinations<int>.Count(4, 2), Is.EqualTo(6));
Assert.That(CCombinations<int>.Count(12, 2), Is.EqualTo(66));
// Corner cases
for (int i = 1; i < 12; i++)
for (var i = 1; i < 12; i++)
{
Assert.AreEqual(1, CCombinations<int>.Count(i, 0));
Assert.AreEqual(1, CCombinations<int>.Count(i, i));
Assert.AreEqual(0, CCombinations<int>.Count(i, i + 1));
Assert.That(CCombinations<int>.Count(i, 0), Is.EqualTo(1));
Assert.That(CCombinations<int>.Count(i, i), Is.EqualTo(1));
Assert.That(CCombinations<int>.Count(i, i + 1), Is.EqualTo(0));
}
// Check identity (n k) = (n n-k)
for (int i = 0; i <= 12; i++)
Assert.AreEqual(CCombinations<int>.Count(12, i), CCombinations<int>.Count(12, 12 - i));
Assert.That(() => CCombinations<int>.Count(-1, -1), Throws.TypeOf<ArgumentException>());
Assert.That(() => CCombinations<int>.Count(-1, 1), Throws.TypeOf<ArgumentException>());
Assert.That(() => CCombinations<int>.Count(1, -1), Throws.TypeOf<ArgumentException>());
for (var i = 0; i <= 12; i++)
{
Assert.That(CCombinations<int>.Count(12, 12 - i), Is.EqualTo(CCombinations<int>.Count(12, i)));
}
Assert.Throws<ArgumentException>(new Action(() => CCombinations<int>.Count(-1, -1)));
Assert.Throws<ArgumentException>(new Action(() => CCombinations<int>.Count(-1, 1)));
Assert.Throws<ArgumentException>(new Action(() => CCombinations<int>.Count(1, -1)));
}
[Test]
public void TestResults([Range(0, 8, 1)] int n)
{
Random rand = new Random();
for (int k = 0; k <= n; k++)
var rand = new Random();
for (var k = 0; k <= n; k++)
{
List<int> collection = new List<int>(n);
int r = rand.Next(1000);
for (int i = 0; i < n; i++)
var collection = new List<int>(n);
var r = rand.Next(1000);
for (var i = 0; i < n; i++)
{
collection.Add(i + r);
CCombinations<int> combs = new CCombinations<int>(collection, k);
Assert.AreEqual(CCombinations<int>.Count(n, k), combs.Count());
}
var combs = new CCombinations<int>(collection, k);
Assert.That(combs.Count(), Is.EqualTo(CCombinations<int>.Count(n, k)));
_CheckResults(combs, collection);
}
}
#endregion
#region Helper methods
// ReSharper disable UnusedParameter.Local
private static void _CheckResults<T>(CCombinations<T> combs, List<T> input)
// ReSharper restore UnusedParameter.Local
// ReSharper restore UnusedParameter.Local
{
List<List<T>> results = new List<List<T>>();
foreach (List<T> comb in combs)
var results = new List<List<T>>();
foreach (var comb in combs)
{
foreach (List<T> other in results)
Assert.IsFalse(other.SequenceEqual(comb), "Result must be unique");
for (int i = 0; i < comb.Count - 1; i++)
foreach (var other in results)
{
Assert.IsTrue(comb.IndexOf(comb[i], i + 1) < 0, "Repetition not allowed");
Assert.IsTrue(input.Contains(comb[i]), "Output must be in input sequence");
Assert.That(other.SequenceEqual(comb), Is.False, "Result must be unique");
}
for (var i = 0; i < comb.Count - 1; i++)
{
Assert.That(comb.IndexOf(comb[i], i + 1), Is.LessThan(0),"Repetition not allowed");
Assert.That(input.Contains(comb[i]), Is.True, "Output must be in input sequence");
}
results.Add(comb);
}
Assert.AreEqual(combs.Count(), results.Count);
List<List<T>> results2 = combs.GetAll();
Assert.AreEqual(results.Count, results2.Count);
for (int i = 0; i < results2.Count; i++)
Assert.IsTrue(results[i].SequenceEqual(results2[i]));
}
Assert.That(results, Has.Count.EqualTo(combs.Count()));
var results2 = combs.GetAll();
Assert.That(results, Has.Count.EqualTo(results2.Count));
for (var i = 0; i < results2.Count; i++)
{
Assert.That(results[i], Is.EquivalentTo(results2[i]));
}
}
#endregion
}
}
}