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

+34 -41
View File
@@ -15,7 +15,6 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.IO;
using NUnit.Framework;
using VocaluxeLib.Log;
@@ -28,7 +27,6 @@ namespace Tests.VocaluxeLib.Log
private string _TestFolder;
#region Setup methods
[SetUp]
public void SetUp()
{
@@ -40,18 +38,16 @@ namespace Tests.VocaluxeLib.Log
{
Directory.Delete(_TestFolder, true);
}
#endregion
#region Tests
[Test]
public void BenchmarkTimeTest()
{
const string testMessage = "BenchmarkTime Test";
string testFileName = Path.GetRandomFileName();
string testFileSongName = Path.GetRandomFileName();
string testFileMarkerName = Path.GetRandomFileName();
var testFileName = Path.GetRandomFileName();
var testFileSongName = Path.GetRandomFileName();
var testFileMarkerName = Path.GetRandomFileName();
const string versionTag = "Test Version (1.2.4)";
// Init Log
@@ -68,59 +64,59 @@ namespace Tests.VocaluxeLib.Log
CLog.Close();
// Check log
Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileName)), "Mainlog file is missing.");
Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileSongName)), "Songlog file is missing.");
Assert.That(File.Exists(Path.Combine(_TestFolder, testFileName)), Is.True, "Mainlog file is missing.");
Assert.That(File.Exists(Path.Combine(_TestFolder, testFileSongName)), Is.True, "Songlog file is missing.");
string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
var mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
var songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
StringAssert.Contains($"[Information] Started \"{ testMessage }\"", mainLogContent, "Start entry wrong");
StringAssert.Contains($"[Information] Finished \"{ testMessage }\" successfully in ", mainLogContent, "Finish entry wrong");
StringAssert.AreEqualIgnoringCase("", songLogContent, "Benchmark should not create song log entries");
Assert.That(mainLogContent, Contains.Substring($"[Information] Started \"{testMessage}\""), "Start entry wrong");
Assert.That(mainLogContent, Contains.Substring($"[Information] Finished \"{testMessage}\" successfully in "), "Finish entry wrong");
Assert.That(songLogContent, Is.Empty, "Benchmark should not create song log entries");
}
[Test]
public void BenchmarkBeginTest()
{
const string testMessage = "BenchmarkBegin Test";
string testFileName = Path.GetRandomFileName();
string testFileSongName = Path.GetRandomFileName();
string testFileMarkerName = Path.GetRandomFileName();
var testFileName = Path.GetRandomFileName();
var testFileSongName = Path.GetRandomFileName();
var testFileMarkerName = Path.GetRandomFileName();
const string versionTag = "Test Version (1.2.4)";
// Init Log
CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
(crash, cont, tag, log, error) => { Assert.Fail("Benchmarks should not show the reporter."); },
ELogLevel.Verbose);
using (var token = CBenchmark.Begin(testMessage))
{
System.Threading.Thread.Sleep(1);
token.End();
}
// Close logfile
CLog.Close();
// Check log
Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileName)), "Mainlog file is missing.");
Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileSongName)), "Songlog file is missing.");
Assert.That(File.Exists(Path.Combine(_TestFolder, testFileName)), Is.True, "Mainlog file is missing.");
Assert.That(File.Exists(Path.Combine(_TestFolder, testFileSongName)), Is.True, "Songlog file is missing.");
string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
var mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
var songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
StringAssert.Contains($"[Information] Started \"{ testMessage }\"", mainLogContent, "Start entry wrong");
StringAssert.Contains($"[Information] Finished \"{ testMessage }\" successfully in ", mainLogContent, "Finish entry wrong");
StringAssert.AreEqualIgnoringCase("", songLogContent, "Benchmark should not create song log entries");
Assert.That(mainLogContent, Contains.Substring($"[Information] Started \"{testMessage}\""), "Start entry wrong");
Assert.That(mainLogContent, Contains.Substring($"[Information] Finished \"{testMessage}\" successfully in "), "Finish entry wrong");
Assert.That(songLogContent, Is.Empty, "Benchmark should not create song log entries");
}
[Test]
public void BenchmarkBeginWithoutEndTest()
{
const string testMessage = "BenchmarkBegin Test";
string testFileName = Path.GetRandomFileName();
string testFileSongName = Path.GetRandomFileName();
string testFileMarkerName = Path.GetRandomFileName();
var testFileName = Path.GetRandomFileName();
var testFileSongName = Path.GetRandomFileName();
var testFileMarkerName = Path.GetRandomFileName();
const string versionTag = "Test Version (1.2.4)";
// Init Log
@@ -137,28 +133,25 @@ namespace Tests.VocaluxeLib.Log
CLog.Close();
// Check log
Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileName)), "Mainlog file is missing.");
Assert.IsTrue(File.Exists(Path.Combine(_TestFolder, testFileSongName)), "Songlog file is missing.");
Assert.That(File.Exists(Path.Combine(_TestFolder, testFileName)), Is.True, "Mainlog file is missing.");
Assert.That(File.Exists(Path.Combine(_TestFolder, testFileSongName)), Is.True, "Songlog file is missing.");
string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
var mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
var songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
StringAssert.Contains($"[Information] Started \"{ testMessage }\"", mainLogContent, "Start entry wrong");
StringAssert.Contains($"[Information] Failed \"{ testMessage }\" in ", mainLogContent, "Finish entry wrong");
StringAssert.AreEqualIgnoringCase("", songLogContent, "Benchmark should not create song log entries");
Assert.That(mainLogContent, Contains.Substring($"[Information] Started \"{testMessage}\""), "Start entry wrong");
Assert.That(mainLogContent, Contains.Substring($"[Information] Failed \"{testMessage}\" in "), "Finish entry wrong");
Assert.That(songLogContent, Is.Empty, "Benchmark should not create song log entries");
}
#endregion
#region Helper methods
private string _GetTemporaryDirectory()
{
string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(tempDirectory);
return tempDirectory;
}
#endregion
}
}
}