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
@@ -29,7 +29,6 @@ namespace Tests.VocaluxeLib.Log.Rolling
|
||||
private string _TestFolder;
|
||||
|
||||
#region Setup methods
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
@@ -41,20 +40,18 @@ namespace Tests.VocaluxeLib.Log.Rolling
|
||||
{
|
||||
Directory.Delete(_TestFolder, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tests
|
||||
|
||||
[Test]
|
||||
public void RollFilesTest([Range(0,4)] int numFilesExisting, [Range(0, 3)] int numOldFilesToKeep)
|
||||
public void RollFilesTest([Range(0, 4)] int numFilesExisting, [Range(0, 3)] int numOldFilesToKeep)
|
||||
{
|
||||
// Create existing files
|
||||
if (numFilesExisting > 0)
|
||||
{
|
||||
CreateFile(_TestFolder, _TestFileName, 0);
|
||||
}
|
||||
|
||||
|
||||
for (var i = 1; i < numFilesExisting; i++)
|
||||
{
|
||||
CreateFile(_TestFolder, GetFileName(i), i);
|
||||
@@ -63,33 +60,31 @@ namespace Tests.VocaluxeLib.Log.Rolling
|
||||
|
||||
// Roll the files
|
||||
CLogFileRoller.RollLogs(Path.Combine(_TestFolder, _TestFileName), numOldFilesToKeep);
|
||||
|
||||
|
||||
|
||||
// Check main file
|
||||
Assert.IsFalse(File.Exists(Path.Combine(_TestFolder, _TestFileName)), "Main file was not deleted.");
|
||||
Assert.That(File.Exists(Path.Combine(_TestFolder, _TestFileName)), Is.False, "Main file was not deleted.");
|
||||
//Check other files
|
||||
for (int i = 1; i <= Math.Max(numOldFilesToKeep, numFilesExisting); i++)
|
||||
for (var i = 1; i <= Math.Max(numOldFilesToKeep, numFilesExisting); i++)
|
||||
{
|
||||
var fileToCheck = Path.Combine(_TestFolder, GetFileName(i));
|
||||
if (i <= Math.Min(numFilesExisting,numOldFilesToKeep))
|
||||
if (i <= Math.Min(numFilesExisting, numOldFilesToKeep))
|
||||
{
|
||||
Assert.IsTrue(File.Exists(fileToCheck), $"File {GetFileName(i)} is missing.");
|
||||
Assert.AreEqual((i - 1).ToString(), File.ReadAllText(fileToCheck), "Rotation is wrong");
|
||||
Assert.That(File.Exists(fileToCheck), Is.True, $"File {GetFileName(i)} is missing.");
|
||||
Assert.That(File.ReadAllText(fileToCheck), Is.EqualTo((i - 1).ToString()), "Rotation is wrong");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsFalse(File.Exists(fileToCheck));
|
||||
Assert.That(File.Exists(fileToCheck), Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -103,8 +98,6 @@ namespace Tests.VocaluxeLib.Log.Rolling
|
||||
{
|
||||
return _TestFileName.Replace(".", $"_{i}.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user