diff --git a/.gitignore b/.gitignore
index fd38548a..1a7595d0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,4 +71,5 @@ tx.exe
/Output/x86
/PitchTracker/bin
/PitchTracker/obj
-/Logs
\ No newline at end of file
+/Logs
+/Tests/bin
\ No newline at end of file
diff --git a/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj b/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj
index 80797f3e..7ba34720 100644
--- a/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj
+++ b/PartyModes/PartyModeChallenge/PartyModeChallenge.csproj
@@ -87,6 +87,7 @@
+
@@ -99,9 +100,7 @@
-
-
-
+
if exist "$(SolutionDir)Output\PartyModes\$(TargetName)\Code" rd "$(SolutionDir)Output\PartyModes\$(TargetName)\Code" /S /Q
diff --git a/PartyModes/PartyModeChallenge/Properties/AssemblyInfo.cs b/PartyModes/PartyModeChallenge/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..b60fdd02
--- /dev/null
+++ b/PartyModes/PartyModeChallenge/Properties/AssemblyInfo.cs
@@ -0,0 +1,21 @@
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System.Runtime.CompilerServices;
+
+// Allow internal access from the Tests project
+[assembly: InternalsVisibleTo("Tests")]
\ No newline at end of file
diff --git a/Tests/PartyModeChallenge/CPartyModeChallangeTest.cs b/Tests/PartyModeChallenge/CPartyModeChallangeTest.cs
new file mode 100644
index 00000000..502a16f1
--- /dev/null
+++ b/Tests/PartyModeChallenge/CPartyModeChallangeTest.cs
@@ -0,0 +1,89 @@
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
+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
+{
+ [TestFixture]
+ 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++)
+ {
+ int invL = inv;
+ // ReSharper disable ObjectCreationAsStatement
+ Assert.Throws(() => new CChallengeRounds(invL, 1, 1));
+ Assert.Throws(() => new CChallengeRounds(1, invL, 1));
+ Assert.Throws(() => new CChallengeRounds(1, 1, invL));
+ // ReSharper restore ObjectCreationAsStatement
+ }
+ }
+
+ [Test]
+ public void TestRoundGeneration([Range(1, 20)] int numPlayer, [Range(1, 6)] int numMic)
+ {
+ CBase.Game = new CBGame();
+
+ int roundFactor = (numPlayer % numMic == 0) ? numPlayer / numMic : numPlayer;
+ for (int numRounds = roundFactor; numRounds <= 100 && numRounds <= roundFactor * 5; numRounds += roundFactor)
+ {
+ CChallengeRounds rounds = new CChallengeRounds(numRounds, numPlayer, numMic);
+ Assert.IsTrue(rounds.Count >= numRounds);
+ _CheckRounds(rounds, numPlayer);
+ Warn.If(rounds.Count != numRounds,
+ $"Number of rounds does not match. Expected: {numRounds}, Is: {rounds.Count} for {numPlayer}/{((numPlayer < numMic) ? numPlayer : numMic)}");
+ }
+ }
+
+ #endregion
+
+ #region Helper methods
+ private static void _CheckRounds(CChallengeRounds rounds, int numPlayer)
+ {
+ List numSongs = new List(numPlayer);
+ for (int i = 0; i < numPlayer; i++)
+ numSongs.Add(0);
+ for (int i = 0; i < rounds.Count; i++)
+ {
+ foreach (int player in rounds[i].Players)
+ {
+ Assert.IsTrue(player >= 0 && player < numPlayer);
+ numSongs[player]++;
+ }
+ }
+ Assert.IsTrue(numSongs.Min() == numSongs.Max(), "Some players have more songs than others");
+ }
+
+ #endregion
+ }
+}
diff --git a/Tests/Properties/AssemblyInfo.cs b/Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..bb5ab59a
--- /dev/null
+++ b/Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Vocaluxe Tests")]
+[assembly: AssemblyDescription("Testcases for Vocaluxe")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Vocaluxe Team")]
+[assembly: AssemblyProduct("VocluceTests")]
+[assembly: AssemblyCopyright("Copyright © 2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
new file mode 100644
index 00000000..878dce8a
--- /dev/null
+++ b/Tests/Tests.csproj
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+ Debug
+ x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}
+ Library
+ Properties
+ Tests
+ Tests
+ v4.7.1
+ 512
+
+
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x86
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ x86
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x64
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ x64
+
+
+
+ ..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll
+ True
+
+
+
+
+
+
+
+ TextTemplatingFileGenerator
+ CLogTest.cs
+
+
+
+ True
+ True
+ CLogTest.tt
+
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+ {5a4053f1-5ad5-441f-b254-d97a088127b6}
+ PartyModeChallenge
+
+
+ {D2B6DDEF-E0E1-4DDF-A73A-E6ACEF5C95EC}
+ VocaluxeLib
+
+
+ {2a1e0f2d-5392-4bb7-b0a1-a9dfa13e79ff}
+ Vocaluxe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tests/VocaluxeLib/Log/CBenchmarkTest.cs b/Tests/VocaluxeLib/Log/CBenchmarkTest.cs
new file mode 100644
index 00000000..54d92fa7
--- /dev/null
+++ b/Tests/VocaluxeLib/Log/CBenchmarkTest.cs
@@ -0,0 +1,164 @@
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
+using System.IO;
+using NUnit.Framework;
+using VocaluxeLib.Log;
+
+namespace Tests.VocaluxeLib.Log
+{
+ [TestFixture]
+ public class CBenchmarkTest
+ {
+ private string _TestFolder;
+
+ #region Setup methods
+
+ [SetUp]
+ public void SetUp()
+ {
+ _TestFolder = _GetTemporaryDirectory();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ 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();
+ 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 (CBenchmark.Time(testMessage))
+ {
+ System.Threading.Thread.Sleep(1);
+ }
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string 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");
+ }
+
+ [Test]
+ public void BenchmarkBeginTest()
+ {
+ const string testMessage = "BenchmarkBegin Test";
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string 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");
+ }
+
+ [Test]
+ public void BenchmarkBeginWithoutEndTest()
+ {
+ const string testMessage = "BenchmarkBegin Test";
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string 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);
+ }
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string 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");
+ }
+
+ #endregion
+
+ #region Helper methods
+
+ private string _GetTemporaryDirectory()
+ {
+ string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ Directory.CreateDirectory(tempDirectory);
+ return tempDirectory;
+ }
+
+ #endregion
+ }
+}
diff --git a/Tests/VocaluxeLib/Log/CLogTest.cs b/Tests/VocaluxeLib/Log/CLogTest.cs
new file mode 100644
index 00000000..56ddf159
--- /dev/null
+++ b/Tests/VocaluxeLib/Log/CLogTest.cs
@@ -0,0 +1,1124 @@
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
+using System.IO;
+using NUnit.Framework;
+using VocaluxeLib.Log;
+
+namespace Tests.VocaluxeLib.Log
+{
+ [TestFixture]
+ public class CLogTest
+ {
+ private const string _TestMessage = "This is a test";
+ private const string _TestMessageWithData = "This is a test with data: {Data1}";
+ private const string _FirstParam = "Test";
+ private const string _SecondParam = "Foo";
+ private const string _TestMessageWithResolvedData = "This is a test with data: \"Test\"";
+ private const string _TestExceptionMessage = "TestExceptionMessage";
+ private string _TestFolder;
+
+ #region Setup methods
+
+ [SetUp]
+ public void SetUp()
+ {
+ _TestFolder = _GetTemporaryDirectory();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Directory.Delete(_TestFolder, true);
+ }
+
+ #endregion
+
+ #region Tests
+
+ #region Verbose tests
+
+ [Test]
+ public void VerboseTestWithDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Verbose(new Exception(_TestExceptionMessage), _TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Verbose(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void VerboseTestWithDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Verbose(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Verbose(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void VerboseTestWithoutDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Verbose(new Exception(_TestExceptionMessage), _TestMessage, show);
+ CLog.CSongLog.Verbose(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void VerboseTestWithoutDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Verbose(_TestMessage, show);
+ CLog.CSongLog.Verbose(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Verbose] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ #endregion
+ #region Debug tests
+
+ [Test]
+ public void DebugTestWithDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Debug(new Exception(_TestExceptionMessage), _TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Debug(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void DebugTestWithDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Debug(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Debug(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void DebugTestWithoutDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Debug(new Exception(_TestExceptionMessage), _TestMessage, show);
+ CLog.CSongLog.Debug(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void DebugTestWithoutDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Debug(_TestMessage, show);
+ CLog.CSongLog.Debug(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Debug] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ #endregion
+ #region Information tests
+
+ [Test]
+ public void InformationTestWithDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Information(new Exception(_TestExceptionMessage), _TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Information(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void InformationTestWithDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Information(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Information(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void InformationTestWithoutDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Information(new Exception(_TestExceptionMessage), _TestMessage, show);
+ CLog.CSongLog.Information(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void InformationTestWithoutDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Information(_TestMessage, show);
+ CLog.CSongLog.Information(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Information] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ #endregion
+ #region Warning tests
+
+ [Test]
+ public void WarningTestWithDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Warning(new Exception(_TestExceptionMessage), _TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Warning(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void WarningTestWithDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Warning(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Warning(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void WarningTestWithoutDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Warning(new Exception(_TestExceptionMessage), _TestMessage, show);
+ CLog.CSongLog.Warning(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void WarningTestWithoutDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Warning(_TestMessage, show);
+ CLog.CSongLog.Warning(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Warning] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ #endregion
+ #region Error tests
+
+ [Test]
+ public void ErrorTestWithDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Error(new Exception(_TestExceptionMessage), _TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Error(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void ErrorTestWithDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " + _TestMessageWithResolvedData, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessageWithData, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Error(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam), show);
+ CLog.CSongLog.Error(_TestMessageWithData, CLog.Params(_FirstParam, _SecondParam));
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " +_TestMessageWithResolvedData, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+ StringAssert.Contains(_TestMessageWithResolvedData, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void ErrorTestWithoutDataWithException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Error(new Exception(_TestExceptionMessage), _TestMessage, show);
+ CLog.CSongLog.Error(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ [Test]
+ public void ErrorTestWithoutDataWithoutException([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " + _TestMessage, log, "Main log entry wrong");
+
+ StringAssert.Contains(_TestMessage, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.Error(_TestMessage, show);
+ CLog.CSongLog.Error(_TestMessage);
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[Error] " +_TestMessage, mainLogContent, "Main log entry wrong");
+ StringAssert.Contains(_TestMessage, songLogContent, "Song log entry wrong");
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Helper methods
+
+ private string _GetTemporaryDirectory()
+ {
+ string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ Directory.CreateDirectory(tempDirectory);
+ return tempDirectory;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/Tests/VocaluxeLib/Log/CLogTest.tt b/Tests/VocaluxeLib/Log/CLogTest.tt
new file mode 100644
index 00000000..fac62cfb
--- /dev/null
+++ b/Tests/VocaluxeLib/Log/CLogTest.tt
@@ -0,0 +1,161 @@
+<#
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#>
+<#@ template debug="false" hostspecific="false" language="C#" #>
+<#@ assembly name="System.Core" #>
+<#@ import namespace="System.Linq" #>
+<#@ import namespace="System.Text" #>
+<#@ import namespace="System.Collections.Generic" #>
+<#@ output extension=".cs" #>
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
+using System.IO;
+using NUnit.Framework;
+using VocaluxeLib.Log;
+
+namespace Tests.VocaluxeLib.Log
+{
+ [TestFixture]
+ public class CLogTest
+ {
+ private const string _TestMessage = "This is a test";
+ private const string _TestMessageWithData = "This is a test with data: {Data1}";
+ private const string _FirstParam = "Test";
+ private const string _SecondParam = "Foo";
+ private const string _TestMessageWithResolvedData = "This is a test with data: \"Test\"";
+ private const string _TestExceptionMessage = "TestExceptionMessage";
+ private string _TestFolder;
+
+ #region Setup methods
+
+ [SetUp]
+ public void SetUp()
+ {
+ _TestFolder = _GetTemporaryDirectory();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Directory.Delete(_TestFolder, true);
+ }
+
+ #endregion
+
+ #region Tests
+
+<# foreach (var LogLevel in new[]{"Verbose","Debug", "Information", "Warning", "Error"/*, "Fatal"*/}) { /* Fatal calls Environment.Exit -> cant test without mock*/ #>
+ #region <#= LogLevel #> tests
+<# foreach (var WithData in new[] {true, false}) { #>
+<# foreach (var WithException in new[] {true, false}) { #>
+
+ [Test]
+ public void <#= LogLevel #>Test<#= WithData?"With":"Without" #>Data<#= WithException?"With":"Without" #>Exception([Values(true, false)] bool show)
+ {
+ string testFileName = Path.GetRandomFileName();
+ string testFileSongName = Path.GetRandomFileName();
+ string testFileMarkerName = Path.GetRandomFileName();
+ string versionTag = "Test Version (1.2.4)";
+ bool messageShown = false;
+
+ // Init Log
+ CLog.Init(_TestFolder, testFileName, testFileSongName, testFileMarkerName, versionTag,
+ (crash, cont, tag, log, error) =>
+ {
+ messageShown = true;
+ Assert.IsTrue(show);
+ Assert.IsFalse(crash);
+ Assert.IsTrue(cont);
+ Assert.AreEqual(versionTag, tag);
+
+ StringAssert.Contains("[Information] Starting to log", log, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, log, "Main log version tag entry wrong");
+ StringAssert.Contains("[<#= LogLevel #>] " + <#= WithData?"_TestMessageWithResolvedData":"_TestMessage" #>, log, "Main log entry wrong");
+
+ StringAssert.Contains(<#= WithData?"_TestMessageWithData":"_TestMessage" #>, error, "Error message wrong");
+ },
+ ELogLevel.Verbose);
+
+ // Add log entry
+ CLog.<#= LogLevel #>(<#= WithException?"new Exception(_TestExceptionMessage), ":"" #><#= WithData?"_TestMessageWithData":"_TestMessage" #><#= WithData?", CLog.Params(_FirstParam, _SecondParam)":"" #>, show);
+<# if(LogLevel!="Fatal") { #>
+ CLog.CSongLog.<#= LogLevel #>(<#= WithData?"_TestMessageWithData":"_TestMessage" #><#= WithData?", CLog.Params(_FirstParam, _SecondParam)":"" #>);
+<# } #>
+
+ // 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.");
+
+ string mainLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileName));
+ string songLogContent = File.ReadAllText(Path.Combine(_TestFolder, testFileSongName));
+
+ StringAssert.Contains("[Information] Starting to log", mainLogContent, "Main log start entry wrong");
+ StringAssert.Contains("Version = " + versionTag, mainLogContent, "Main log version tag entry wrong");
+ StringAssert.Contains("[<#= LogLevel #>] " +<#= WithData?"_TestMessageWithResolvedData":"_TestMessage" #>, mainLogContent, "Main log entry wrong");
+<# if(WithException) { #>
+ StringAssert.Contains(_TestExceptionMessage, mainLogContent, "Exception is missing");
+<# } #>
+<# if(WithData) { #>
+ StringAssert.Contains(_SecondParam, mainLogContent, "Second data field is missing");
+<# } #>
+<# if(LogLevel!="Fatal") { #>
+ StringAssert.Contains(<#= WithData?"_TestMessageWithResolvedData":"_TestMessage" #>, songLogContent, "Song log entry wrong");
+<# } #>
+ if(!show)
+ {
+ Assert.IsFalse(messageShown);
+ }
+ }
+<# } #>
+<# } #>
+
+ #endregion
+<# } #>
+
+ #endregion
+
+ #region Helper methods
+
+ private string _GetTemporaryDirectory()
+ {
+ string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ Directory.CreateDirectory(tempDirectory);
+ return tempDirectory;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/Tests/VocaluxeLib/Log/Rolling/CLogFileRollerTest.cs b/Tests/VocaluxeLib/Log/Rolling/CLogFileRollerTest.cs
new file mode 100644
index 00000000..b8089613
--- /dev/null
+++ b/Tests/VocaluxeLib/Log/Rolling/CLogFileRollerTest.cs
@@ -0,0 +1,110 @@
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
+using System.IO;
+using NUnit.Framework;
+using VocaluxeLib.Log.Rolling;
+
+namespace Tests.VocaluxeLib.Log.Rolling
+{
+ [TestFixture]
+ public class CLogFileRollerTest
+ {
+ private const string _TestFileName = "Test.log";
+ private string _TestFolder;
+
+ #region Setup methods
+
+ [SetUp]
+ public void SetUp()
+ {
+ _TestFolder = _GetTemporaryDirectory();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Directory.Delete(_TestFolder, true);
+ }
+
+ #endregion
+
+ #region Tests
+
+ [Test]
+ 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);
+ }
+
+
+ // 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.");
+ //Check other files
+ for (int i = 1; i <= Math.Max(numOldFilesToKeep, numFilesExisting); i++)
+ {
+ var fileToCheck = Path.Combine(_TestFolder, GetFileName(i));
+ 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");
+ }
+ else
+ {
+ Assert.IsFalse(File.Exists(fileToCheck));
+ }
+ }
+ }
+
+ #endregion
+
+ #region Helper methods
+
+ private string _GetTemporaryDirectory()
+ {
+ string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
+ Directory.CreateDirectory(tempDirectory);
+ return tempDirectory;
+ }
+
+ private void CreateFile(string folder, string file, int i)
+ {
+ File.WriteAllText(Path.Combine(folder, file), i.ToString());
+ }
+
+ private string GetFileName(int i)
+ {
+ return _TestFileName.Replace(".", $"_{i}.");
+ }
+
+ #endregion
+
+ }
+}
diff --git a/VocaluxeTests/CombinatoricsTest.cs b/Tests/VocaluxeLib/Utils/Combinatorics/CCombinationsTest.cs
similarity index 51%
rename from VocaluxeTests/CombinatoricsTest.cs
rename to Tests/VocaluxeLib/Utils/Combinatorics/CCombinationsTest.cs
index 50d274e1..dbdf71c9 100644
--- a/VocaluxeTests/CombinatoricsTest.cs
+++ b/Tests/VocaluxeLib/Utils/Combinatorics/CCombinationsTest.cs
@@ -1,16 +1,35 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NUnit.Framework;
using VocaluxeLib.Utils.Combinatorics;
-namespace VocaluxeTests
+namespace Tests.VocaluxeLib.Utils.Combinatorics
{
- [TestClass]
- public class CCombinatoricsTest
+ [TestFixture]
+ public class CCombinationsTest
{
- [TestMethod]
- public void TestCounts()
+ #region Tests
+
+ [Test]
+ public void TestCount()
{
Assert.AreEqual(4, CCombinations.Count(4, 3));
Assert.AreEqual(6, CCombinations.Count(4, 2));
@@ -25,14 +44,35 @@ namespace VocaluxeTests
// Check identity (n k) = (n n-k)
for (int i = 0; i <= 12; i++)
Assert.AreEqual(CCombinations.Count(12, i), CCombinations.Count(12, 12 - i));
- CTestHelpers.AssertFail(() => CCombinations.Count(-1, -1));
- CTestHelpers.AssertFail(() => CCombinations.Count(-1, 1));
- CTestHelpers.AssertFail(() => CCombinations.Count(1, -1));
+ Assert.That(() => CCombinations.Count(-1, -1), Throws.TypeOf());
+ Assert.That(() => CCombinations.Count(-1, 1), Throws.TypeOf());
+ Assert.That(() => CCombinations.Count(1, -1), Throws.TypeOf());
}
+ [Test]
+ public void TestResults([Range(0, 8, 1)] int n)
+ {
+ Random rand = new Random();
+
+ for (int k = 0; k <= n; k++)
+ {
+ List collection = new List(n);
+ int r = rand.Next(1000);
+ for (int i = 0; i < n; i++)
+ collection.Add(i + r);
+ CCombinations combs = new CCombinations(collection, k);
+ Assert.AreEqual(CCombinations.Count(n, k), combs.Count());
+ _CheckResults(combs, collection);
+ }
+ }
+
+ #endregion
+
+ #region Helper methods
+
// ReSharper disable UnusedParameter.Local
private static void _CheckResults(CCombinations combs, List input)
- // ReSharper restore UnusedParameter.Local
+ // ReSharper restore UnusedParameter.Local
{
List> results = new List>();
foreach (List comb in combs)
@@ -53,23 +93,6 @@ namespace VocaluxeTests
Assert.IsTrue(results[i].SequenceEqual(results2[i]));
}
- [TestMethod]
- public void TestResults()
- {
- Random rand = new Random();
- for (int n = 0; n < 8; n++)
- {
- for (int k = 0; k <= n; k++)
- {
- List collection = new List(n);
- int r = rand.Next(1000);
- for (int i = 0; i < n; i++)
- collection.Add(i + r);
- CCombinations combs = new CCombinations(collection, k);
- Assert.AreEqual(CCombinations.Count(n, k), combs.Count());
- _CheckResults(combs, collection);
- }
- }
- }
+ #endregion
}
-}
\ No newline at end of file
+}
diff --git a/VocaluxeTests/XmlSerializerTest.cs b/Tests/VocaluxeLib/XML/CXmlSerializerTest.cs
similarity index 79%
rename from VocaluxeTests/XmlSerializerTest.cs
rename to Tests/VocaluxeLib/XML/CXmlSerializerTest.cs
index 91605a7e..8c027489 100644
--- a/VocaluxeTests/XmlSerializerTest.cs
+++ b/Tests/VocaluxeLib/XML/CXmlSerializerTest.cs
@@ -1,128 +1,41 @@
-using System;
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Xml.Serialization;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Vocaluxe.Base;
+using NUnit.Framework;
using VocaluxeLib;
-using VocaluxeLib.Menu;
using VocaluxeLib.Xml;
+using Vocaluxe.Base;
-namespace VocaluxeTests
+namespace Tests.VocaluxeLib.XML
{
- [TestClass]
+ [TestFixture]
public class CXmlSerializerTest
{
private const string _Head = "\r\n";
private const string _Empty = _Head + @"";
-#pragma warning disable 649
-#pragma warning disable 169
- private struct SBasic
- {
- public int I;
- public string S;
- public float F;
- public double D;
- }
+ #region Tests
- [XmlType("Entry")]
- private struct SEntry
- {
- public int I;
- }
-
- private struct SList
- {
- [XmlArray] public List Ints;
- }
-
- private struct SArray
- {
- [XmlArray] public SEntry[] Ints;
- }
-
- private struct SListEmb
- {
- public int I;
- [XmlElement("Entry")] public List Ints;
- public int J;
- }
-
- private struct SArrayEmb
- {
- public int I;
- [XmlElement("Entry")] public SEntry[] Ints;
- public int J;
- }
-
- private struct SProperty
- {
- [XmlIgnore] public int Private;
- // ReSharper disable UnusedMember.Local
- public int Public
- {
- get { return Private - 1; }
- set { Private = value + 1; }
- }
- // ReSharper restore UnusedMember.Local
- // ReSharper disable UnusedAutoPropertyAccessor.Local
- public int Auto { get; set; }
- // ReSharper restore UnusedAutoPropertyAccessor.Local
- }
-
- private struct SBytes
- {
- public byte[] B;
- }
-
- private struct SIgnore
- {
- [XmlIgnore] public int I;
- public int J;
- }
-
- private class CIgnore
- {
- [XmlIgnore] public int I;
- public int J;
- }
-
- private struct SDefaultSub
- {
- [DefaultValue(111)] public int I;
- }
-
- private struct SDefault
- {
- [DefaultValue(1337)] public int I;
- [DefaultValue("Foo")] public string S;
- public float? F;
- [DefaultValue(666.0)] public double D;
- public SDefaultSub Sub;
- }
-
-#pragma warning restore 169
-#pragma warning restore 649
-
- private static void _AssertFail(String xmlString) where T2 : Exception where T : new()
- {
- var deserializer = new CXmlDeserializer();
- CTestHelpers.AssertFail(() => deserializer.DeserializeString(xmlString));
- }
-
- private static T _AssertSerDeserMatch(string xmlString) where T : new()
- {
- var deserializer = new CXmlDeserializer();
- var serializer = new CXmlSerializer();
- T foo = deserializer.DeserializeString(xmlString);
- string xmlNew = serializer.Serialize(foo);
- Assert.AreEqual(xmlString, xmlNew);
- return foo;
- }
-
- [TestMethod]
+ [Test]
public void TestBasic()
{
const string s = @"
@@ -150,10 +63,10 @@ namespace VocaluxeTests
Assert.AreEqual(4, foo.D, 0.0001);
}
- [TestMethod]
+ [Test]
public void TestMissingXmlElement()
{
- string[] s = new string[] {@"
+ string[] s = new string[] { @"
2
3
4
@@ -165,7 +78,7 @@ namespace VocaluxeTests
1
2
3
-"};
+" };
foreach (string s1 in s)
{
string sTmp = s1;
@@ -173,10 +86,10 @@ namespace VocaluxeTests
}
}
- [TestMethod]
+ [Test]
public void TestMissingStructElement()
{
- string[] s = new string[] {@"
+ string[] s = new string[] { @"
1
1
2
@@ -194,7 +107,7 @@ namespace VocaluxeTests
3
4
1
-"};
+" };
foreach (string s1 in s)
{
string sTmp = s1;
@@ -202,7 +115,7 @@ namespace VocaluxeTests
}
}
- [TestMethod]
+ [Test]
public void TestBasicSerialization()
{
const string s = _Head + @"
@@ -235,7 +148,7 @@ namespace VocaluxeTests
"
};
- [TestMethod]
+ [Test]
public void TestList()
{
var xml = new CXmlDeserializer();
@@ -258,7 +171,7 @@ namespace VocaluxeTests
_AssertFail(_Empty);
}
- [TestMethod]
+ [Test]
public void TestArray()
{
var xml = new CXmlDeserializer();
@@ -307,7 +220,7 @@ namespace VocaluxeTests
3
";
- [TestMethod]
+ [Test]
public void TestListEmbedded()
{
var xml = new CXmlDeserializer();
@@ -333,7 +246,7 @@ namespace VocaluxeTests
_AssertFail(_Empty);
}
- [TestMethod]
+ [Test]
public void TestArrayEmbedded()
{
var xml = new CXmlDeserializer();
@@ -359,7 +272,7 @@ namespace VocaluxeTests
_AssertFail(_Empty);
}
- [TestMethod]
+ [Test]
public void TestProperty()
{
const string xmlString = _Head + @"
@@ -371,7 +284,7 @@ namespace VocaluxeTests
Assert.AreEqual(3, foo.Auto);
}
- [TestMethod]
+ [Test]
public void TestByteArray()
{
const string xmlString = _Head + @"
@@ -388,31 +301,31 @@ namespace VocaluxeTests
2
";
- [TestMethod]
+ [Test]
public void TestIgnore()
{
_AssertSerDeserMatch(_XmlIgnore);
_AssertFail(_XmlIgnore2);
}
- [TestMethod]
+ [Test]
public void TestExisting()
{
- var foo = new SIgnore {I = 1};
+ var foo = new SIgnore { I = 1 };
var xml = new CXmlDeserializer();
var ser = new CXmlSerializer();
SIgnore bar = xml.DeserializeString(_XmlIgnore, foo);
Assert.AreEqual(1, bar.I);
Assert.AreEqual(_XmlIgnore, ser.Serialize(bar));
- var foo2 = new CIgnore {I = 1};
+ var foo2 = new CIgnore { I = 1 };
CIgnore bar2 = xml.DeserializeString(_XmlIgnore, foo2);
Assert.AreEqual(1, bar2.I);
Assert.AreEqual(foo2.J, bar2.J, "Original classes should be modified by the deserialization");
Assert.AreEqual(_XmlIgnore, ser.Serialize(bar2));
}
- [TestMethod]
+ [Test]
public void TestOnlyList()
{
const string s = _Head + @"
@@ -422,7 +335,7 @@ namespace VocaluxeTests
_AssertSerDeserMatch>(s);
}
- [TestMethod]
+ [Test]
public void TestOnlyDict()
{
const string s = _Head + @"
@@ -432,7 +345,7 @@ namespace VocaluxeTests
_AssertSerDeserMatch>(s);
}
- [TestMethod]
+ [Test]
public void TestDefaultValues()
{
const string s = _Head + @"
@@ -458,33 +371,148 @@ namespace VocaluxeTests
", newXml);
}
- [TestMethod]
- public void TestRealFiles()
+ [Test]
+ public void TestRealFiles([Values(typeof(SThemeCover), typeof(CConfig.SConfig), /*typeof(SThemeScreen),*/ typeof(SDefaultFonts), typeof(SSkin), typeof(STheme), typeof(Dictionary))] Type type)
{
- Type[] types = new Type[]
- {typeof(SThemeCover), typeof(CConfig.SConfig), typeof(SThemeScreen), typeof(SDefaultFonts), typeof(SSkin), typeof(STheme), typeof(Dictionary)};
- string filePath = Path.Combine(new string[] {AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "TestXmlFiles"});
- foreach (Type type in types)
- {
- string xmlPath = Path.Combine(filePath, type.Name + ".xml");
- var deser = new CXmlDeserializer();
- object foo = null;
- try
- {
- foo = deser.Deserialize(xmlPath, Activator.CreateInstance(type));
- }
- catch (Exception e)
- {
- Assert.Fail("Exception with " + type.Name + ": {0}", new object[] {e.Message});
- }
- Assert.IsInstanceOfType(foo, type, "Wrong type with " + type.Name);
- var ser = new CXmlSerializer(type == typeof(CConfig.SConfig));
- string newXml = ser.Serialize(foo, type == typeof(Dictionary) ? "resources" : null);
- // Typename will be uppercase but input is lowercase
- newXml = newXml.Replace(") ? "resources" : null);
+ // Typename will be uppercase but input is lowercase
+ newXml = newXml.Replace(" Ints;
+ }
+
+ private struct SArray
+ {
+ [XmlArray]
+ public SEntry[] Ints;
+ }
+
+ private struct SListEmb
+ {
+ public int I;
+ [XmlElement("Entry")]
+ public List Ints;
+ public int J;
+ }
+
+ private struct SArrayEmb
+ {
+ public int I;
+ [XmlElement("Entry")]
+ public SEntry[] Ints;
+ public int J;
+ }
+
+ private struct SProperty
+ {
+ [XmlIgnore]
+ public int Private;
+ // ReSharper disable UnusedMember.Local
+ public int Public
+ {
+ get { return Private - 1; }
+ set { Private = value + 1; }
+ }
+ // ReSharper restore UnusedMember.Local
+ // ReSharper disable UnusedAutoPropertyAccessor.Local
+ public int Auto { get; set; }
+ // ReSharper restore UnusedAutoPropertyAccessor.Local
+ }
+
+ private struct SBytes
+ {
+ public byte[] B;
+ }
+
+ private struct SIgnore
+ {
+ [XmlIgnore]
+ public int I;
+ public int J;
+ }
+
+ private class CIgnore
+ {
+ [XmlIgnore]
+ public int I;
+ public int J;
+ }
+
+ private struct SDefaultSub
+ {
+ [DefaultValue(111)]
+ public int I;
+ }
+
+ private struct SDefault
+ {
+ [DefaultValue(1337)]
+ public int I;
+ [DefaultValue("Foo")]
+ public string S;
+ public float? F;
+ [DefaultValue(666.0)]
+ public double D;
+ public SDefaultSub Sub;
+ }
+
+#pragma warning restore 169
+#pragma warning restore 649
+
+ private static void _AssertFail(String xmlString) where T2 : Exception where T : new()
+ {
+ var deserializer = new CXmlDeserializer();
+
+ Exception exception =
+ Assert.Catch(() => deserializer.DeserializeString(xmlString));
+ Assert.IsInstanceOf(typeof(T2), exception);
+ }
+
+ private static T _AssertSerDeserMatch(string xmlString) where T : new()
+ {
+ var deserializer = new CXmlDeserializer();
+ var serializer = new CXmlSerializer();
+ T foo = deserializer.DeserializeString(xmlString);
+ string xmlNew = serializer.Serialize(foo);
+ Assert.AreEqual(xmlString, xmlNew);
+ return foo;
+ }
+
+ #endregion
}
-}
\ No newline at end of file
+}
diff --git a/VocaluxeTests/TestXmlFiles/Dictionary`2.xml b/Tests/VocaluxeLib/XML/TestFiles/Dictionary`2.xml
similarity index 100%
rename from VocaluxeTests/TestXmlFiles/Dictionary`2.xml
rename to Tests/VocaluxeLib/XML/TestFiles/Dictionary`2.xml
diff --git a/Tests/VocaluxeLib/XML/TestFiles/SConfig.xml b/Tests/VocaluxeLib/XML/TestFiles/SConfig.xml
new file mode 100644
index 00000000..740a0a5b
--- /dev/null
+++ b/Tests/VocaluxeLib/XML/TestFiles/SConfig.xml
@@ -0,0 +1,133 @@
+
+
+
+ Vocaluxe 'Blue Sunrise' 0.4.0 (x64) (0.4.0-261-gd0c81b4d9)
+
+ Win32NT
+ Microsoft Windows NT 6.2.9200.0
+ 4
+ 2
+ {Width=1920, Height=1080}
+ D:\Vocaluxe\
+
+
+ TR_CONFIG_OFF
+ TR_CONFIG_OFF
+
+
+ TR_CONFIG_DIRECT3D
+ TR_CONFIG_TEXTURE_MEDIUM
+ 256
+ 1
+ 1024
+ 576
+ Middle
+ 0
+ 0
+ 0
+ 0
+ X0
+ 60
+ TR_CONFIG_ON
+ TR_CONFIG_ON
+ TR_CONFIG_OFF
+ 0.4
+
+
+ Genius
+ Standard
+ Genius Standard
+ TR_CONFIG_ON
+ TR_CONFIG_ON
+ TR_CONFIG_TIMERLOOK_EXPANDED
+ TR_CONFIG_PLAYERINFO_BOTH
+ TR_CONFIG_FADEPLAYERINFO_OFF
+ TR_CONFIG_COVERLOADING_DYNAMIC
+ TR_CONFIG_LYRICSTYLE_SLIDE
+
+
+ GstreamerSharp
+ PortAudio
+ B2048
+ 0
+ TR_CONFIG_ON
+ 30
+ TR_CONFIG_NO_OWN_MUSIC
+ TR_CONFIG_ON
+ 50
+ 80
+ TR_CONFIG_OFF
+ 1
+
+
+ English
+ D:\Vocaluxe\Songs
+ TR_CONFIG_TILE_BOARD
+ TR_CONFIG_ARTIST
+ TR_CONFIG_ON
+ TR_CONFIG_TIMERMODE_REMAINING
+ 2
+ TR_CONFIG_OFF
+ TR_CONFIG_OFF
+ 500
+ TR_CONFIG_LYRICSPOSITION_BOTTOM
+ 0.1
+
+
+
+
+
+
+
+
+ TR_CONFIG_HIGHSCORE_LIST_BEST
+
+
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+ 200
+
+
+ TR_CONFIG_OFF
+ TR_CONFIG_OFF
+ 3000
+ 70
+
+
\ No newline at end of file
diff --git a/VocaluxeTests/TestXmlFiles/SDefaultFonts.xml b/Tests/VocaluxeLib/XML/TestFiles/SDefaultFonts.xml
similarity index 100%
rename from VocaluxeTests/TestXmlFiles/SDefaultFonts.xml
rename to Tests/VocaluxeLib/XML/TestFiles/SDefaultFonts.xml
diff --git a/VocaluxeTests/TestXmlFiles/SSkin.xml b/Tests/VocaluxeLib/XML/TestFiles/SSkin.xml
similarity index 100%
rename from VocaluxeTests/TestXmlFiles/SSkin.xml
rename to Tests/VocaluxeLib/XML/TestFiles/SSkin.xml
diff --git a/VocaluxeTests/TestXmlFiles/STheme.xml b/Tests/VocaluxeLib/XML/TestFiles/STheme.xml
similarity index 100%
rename from VocaluxeTests/TestXmlFiles/STheme.xml
rename to Tests/VocaluxeLib/XML/TestFiles/STheme.xml
diff --git a/VocaluxeTests/TestXmlFiles/SThemeCover.xml b/Tests/VocaluxeLib/XML/TestFiles/SThemeCover.xml
similarity index 100%
rename from VocaluxeTests/TestXmlFiles/SThemeCover.xml
rename to Tests/VocaluxeLib/XML/TestFiles/SThemeCover.xml
diff --git a/VocaluxeTests/TestXmlFiles/SThemeScreen.xml b/Tests/VocaluxeLib/XML/TestFiles/SThemeScreen.xml
similarity index 93%
rename from VocaluxeTests/TestXmlFiles/SThemeScreen.xml
rename to Tests/VocaluxeLib/XML/TestFiles/SThemeScreen.xml
index a6751013..716fe674 100644
--- a/VocaluxeTests/TestXmlFiles/SThemeScreen.xml
+++ b/Tests/VocaluxeLib/XML/TestFiles/SThemeScreen.xml
@@ -1,5 +1,5 @@
-
+
ScreenMain
2
@@ -14,25 +14,14 @@
-
- Menu
-
-
- 49
- 32
- 1181
- 50
- 0
-
-
- TextBG
+ Warning
- 150
- 610
- 355
- 30
+ 260
+ 310
+ 760
+ 50
-1.9
@@ -40,7 +29,7 @@
10
- 690
+ 700
-1
15
0
@@ -53,11 +42,11 @@
Vocaluxe "Shining Heaven" v0.3.0 (x64) Beta (0083)
- 320
- 612
+ 640
+ 322
-2
- 27
- 355
+ 25
+ 640
Center
diff --git a/Tests/packages.config b/Tests/packages.config
new file mode 100644
index 00000000..5626b849
--- /dev/null
+++ b/Tests/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Vocaluxe.sln b/Vocaluxe.sln
index a9b3384d..27cbd7c1 100644
--- a/Vocaluxe.sln
+++ b/Vocaluxe.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26730.10
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vocaluxe", "Vocaluxe\Vocaluxe.csproj", "{2A1E0F2D-5392-4BB7-B0A1-A9DFA13E79FF}"
ProjectSection(ProjectDependencies) = postProject
@@ -21,12 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebserverInitalConfig", "We
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PitchTracker", "PitchTracker\PitchTracker.vcxproj", "{54A48AF7-515C-4EDD-B395-2BFFA096050A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VocaluxeTests", "VocaluxeTests\VocaluxeTests.csproj", "{93356718-3A0B-4784-AAE1-215065BFFC66}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2BDDF9CE-271F-49C6-A92E-9CB6185ACF58}"
- ProjectSection(SolutionItems) = preProject
- Vocaluxe.testsettings = Vocaluxe.testsettings
- EndProjectSection
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{8EDF4429-251A-416D-BB68-93F227191BCF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -157,27 +152,26 @@ Global
{54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x64.ActiveCfg = Release|x64
{54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x64.Build.0 = Release|x64
{54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x86.ActiveCfg = Release|Win32
- {54A48AF7-515C-4EDD-B395-2BFFA096050A}.ReleaseWin|x86.Build.0 = Release|Win32
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugLinux|x64.ActiveCfg = Debug|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugLinux|x64.Build.0 = Debug|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugLinux|x86.ActiveCfg = Debug|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugLinux|x86.Build.0 = Debug|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugWin|x64.ActiveCfg = Debug|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugWin|x64.Build.0 = Debug|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugWin|x86.ActiveCfg = Debug|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.DebugWin|x86.Build.0 = Debug|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.InstallerWin|x64.ActiveCfg = Release|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.InstallerWin|x64.Build.0 = Release|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.InstallerWin|x86.ActiveCfg = Release|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.InstallerWin|x86.Build.0 = Release|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseLinux|x64.ActiveCfg = Release|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseLinux|x64.Build.0 = Release|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseLinux|x86.ActiveCfg = Release|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseLinux|x86.Build.0 = Release|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseWin|x64.ActiveCfg = Release|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseWin|x64.Build.0 = Release|x64
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseWin|x86.ActiveCfg = Release|x86
- {93356718-3A0B-4784-AAE1-215065BFFC66}.ReleaseWin|x86.Build.0 = Release|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x64.ActiveCfg = Debug|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x64.Build.0 = Debug|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x86.ActiveCfg = Debug|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugLinux|x86.Build.0 = Debug|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugWin|x64.ActiveCfg = Debug|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugWin|x64.Build.0 = Debug|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugWin|x86.ActiveCfg = Debug|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.DebugWin|x86.Build.0 = Debug|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.InstallerWin|x64.ActiveCfg = Release|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.InstallerWin|x64.Build.0 = Release|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.InstallerWin|x86.ActiveCfg = Release|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.InstallerWin|x86.Build.0 = Release|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseLinux|x64.ActiveCfg = Release|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseLinux|x64.Build.0 = Release|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseLinux|x86.ActiveCfg = Release|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseLinux|x86.Build.0 = Release|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseWin|x64.ActiveCfg = Release|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseWin|x64.Build.0 = Release|x64
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseWin|x86.ActiveCfg = Release|x86
+ {8EDF4429-251A-416D-BB68-93F227191BCF}.ReleaseWin|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Vocaluxe.sln.DotSettings b/Vocaluxe.sln.DotSettings
index 5821e368..a7008703 100644
--- a/Vocaluxe.sln.DotSettings
+++ b/Vocaluxe.sln.DotSettings
@@ -29,7 +29,10 @@
ONLY_FOR_MULTILINE
1
True
+ ALWAYS
+ NEVER
True
+ NEVER
LINE_BREAK
False
True
@@ -117,7 +120,12 @@ along with $SOLUTION$. If not, see <http://www.gnu.org/licenses/>.<Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Classes"><ElementKinds><Kind Name="CLASS" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="C" Suffix="" Style="AaBb" /></Policy>
<Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected" Description="Fields (not public)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /><Kind Name="METHOD" /><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /></Policy>
<Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Structs"><ElementKinds><Kind Name="STRUCT" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="S" Suffix="" Style="AaBb" /></Policy>
+ True
+ True
+ True
+ True
True
+ True
True
True
False
diff --git a/Vocaluxe.testsettings b/Vocaluxe.testsettings
deleted file mode 100644
index ccf7a8c8..00000000
--- a/Vocaluxe.testsettings
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- Dies sind die standardmäßigen Testeinstellungen für einen lokalen Testlauf.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs
index 2f049814..b7a31660 100644
--- a/Vocaluxe/Program.cs
+++ b/Vocaluxe/Program.cs
@@ -91,7 +91,13 @@ namespace Vocaluxe
Directory.CreateDirectory(CSettings.DataFolder);
// Init Log
- CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc);
+ CLog.Init(CSettings.FolderNameLogs,
+ CSettings.FileNameMainLog,
+ CSettings.FileNameSongLog,
+ CSettings.FileNameCrashMarker,
+ CSettings.GetFullVersionText(),
+ CReporter.ShowReporterFunc,
+ ELogLevel.Information);
if (!CProgrammHelper.CheckRequirements())
return;
diff --git a/Vocaluxe/Properties/AssemblyInfo.cs b/Vocaluxe/Properties/AssemblyInfo.cs
index 856b5d45..cc74c35a 100644
--- a/Vocaluxe/Properties/AssemblyInfo.cs
+++ b/Vocaluxe/Properties/AssemblyInfo.cs
@@ -16,6 +16,7 @@
#endregion
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
@@ -52,3 +53,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyVersion("SHORTVERSION")]
[assembly: AssemblyFileVersion("SHORTVERSION")]
[assembly: AssemblyInformationalVersion("GITVERSION")]
+
+
+// Allow internal access from the Tests project
+[assembly:InternalsVisibleTo("Tests")]
diff --git a/VocaluxeLib/Log/CBenchmark.cs b/VocaluxeLib/Log/CBenchmark.cs
index 19ddf6c9..89482654 100644
--- a/VocaluxeLib/Log/CBenchmark.cs
+++ b/VocaluxeLib/Log/CBenchmark.cs
@@ -61,10 +61,10 @@ namespace VocaluxeLib.Log
/// Stops this benchmark.
///
/// If true a success message will be added to the log otherwise a message for failure.
- public void Stop(bool success = true)
+ public void Stop(bool success = true)
{
if (_Watch == null)
- throw new InvalidOperationException("Timer is not running.");
+ return;
_Watch.Stop();
double duration = _GetElapsedTime(_Watch);
diff --git a/VocaluxeLib/Log/CLog.cs b/VocaluxeLib/Log/CLog.cs
index 4c9cb746..e2719273 100644
--- a/VocaluxeLib/Log/CLog.cs
+++ b/VocaluxeLib/Log/CLog.cs
@@ -41,7 +41,6 @@ namespace VocaluxeLib.Log
private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}";
private const string _SongLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}";
-
///
/// Initialize the logging framework.
///
@@ -51,7 +50,8 @@ namespace VocaluxeLib.Log
/// The name of the file which is used as crash marker.
/// The current version tag as it is displayed in the main menu.
/// Delegate to the function which should be called if the reporter have to been shown.
- public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc)
+ /// The log level for log messages.
+ public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc, ELogLevel logLevel)
{
_LogFolder = logFolder;
_ShowReporterFunc = showReporterFunc;
@@ -83,7 +83,11 @@ namespace VocaluxeLib.Log
if (_CurrentVersion == versionTag && File.Exists(mainLogFilePath))
{
string logContent = File.ReadAllText(mainLogFilePath, Encoding.UTF8);
- _ShowReporterFunc(crash:true, showContinue:true, vocaluxeVersionTag:versionTag, log:logContent, lastError:"Vocaluxe crashed while the last execution.");
+ _ShowReporterFunc(crash:true,
+ showContinue:true,
+ vocaluxeVersionTag:versionTag,
+ log:logContent,
+ lastError:"Vocaluxe crashed while the last execution.");
}
#endif
}
@@ -95,26 +99,36 @@ namespace VocaluxeLib.Log
CLogFileRoller.RollLogs(songLogFilePath, 2);
_MainLog = new LoggerConfiguration()
+ .MinimumLevel.Is(logLevel.ToSerilogLogLevel())
.Enrich.WithThreadId()
.Enrich.FromLogContext()
.Enrich.WithTimeStampFromStart()
- .WriteTo.TextWriter(_MainLogStringWriter, outputTemplate: _MainLogTemplate)
+ .WriteTo.TextWriter(_MainLogStringWriter,
+ outputTemplate: _MainLogTemplate)
// Json can be activated by adding "new CompactJsonFormatter()" as first argument
- .WriteTo.File(mainLogFilePath, flushToDiskInterval: TimeSpan.FromSeconds(30), outputTemplate: _MainLogTemplate)
+ .WriteTo.File(mainLogFilePath,
+ flushToDiskInterval: TimeSpan.FromSeconds(30),
+ outputTemplate: _MainLogTemplate)
#if DEBUG
.WriteTo.Console(outputTemplate: _MainLogTemplate)
#endif
.CreateLogger();
_SongLog = new LoggerConfiguration()
- .WriteTo.File(songLogFilePath, flushToDiskInterval: TimeSpan.FromSeconds(60), outputTemplate: _SongLogTemplate)
+ .MinimumLevel.Is(logLevel.ToSerilogLogLevel())
+ .WriteTo.File(songLogFilePath,
+ flushToDiskInterval: TimeSpan.FromSeconds(60),
+ outputTemplate: _SongLogTemplate)
#if DEBUG
.WriteTo.Console(outputTemplate: "[SongInfo] " + _SongLogTemplate)
#endif
.CreateLogger();
// Adding first line to log with information about this run
- Information("Starting to log", Params( new { Version = _CurrentVersion}, new { StartDate = DateTime.Now}, new { Id = Guid.NewGuid() } ) );
+ Information("Starting to log",
+ Params( new { Version = _CurrentVersion},
+ new { StartDate = DateTime.Now},
+ new { Id = Guid.NewGuid() } ) );
}
///
@@ -127,15 +141,15 @@ namespace VocaluxeLib.Log
ILogger loggerToDispose = _MainLog;
_MainLog = new CSilentLogger();
- (_MainLog as IDisposable)?.Dispose();
+ (loggerToDispose as IDisposable)?.Dispose();
}
if (!(_SongLog is CSilentLogger))
{
- ILogger loggerToDispose = _MainLog;
+ ILogger loggerToDispose = _SongLog;
_SongLog = new CSilentLogger();
- (_SongLog as IDisposable)?.Dispose();
+ (loggerToDispose as IDisposable)?.Dispose();
}
// Delete the crash marker
diff --git a/VocaluxeLib/Log/ELogLevel.cs b/VocaluxeLib/Log/ELogLevel.cs
new file mode 100644
index 00000000..d9ebc627
--- /dev/null
+++ b/VocaluxeLib/Log/ELogLevel.cs
@@ -0,0 +1,56 @@
+#region license
+// This file is part of Vocaluxe.
+//
+// Vocaluxe is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Vocaluxe is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Vocaluxe. If not, see .
+#endregion
+
+using System;
+using Serilog.Events;
+
+namespace VocaluxeLib.Log
+{
+ public enum ELogLevel
+ {
+ Verbose,
+ Debug,
+ Information,
+ Warning,
+ Error,
+ Fatal
+ }
+
+ public static class CLogLevelExtension
+ {
+ public static LogEventLevel ToSerilogLogLevel(this ELogLevel level)
+ {
+ switch (level)
+ {
+ case ELogLevel.Verbose:
+ return LogEventLevel.Verbose;
+ case ELogLevel.Debug:
+ return LogEventLevel.Debug;
+ case ELogLevel.Information:
+ return LogEventLevel.Information;
+ case ELogLevel.Warning:
+ return LogEventLevel.Warning;
+ case ELogLevel.Error:
+ return LogEventLevel.Error;
+ case ELogLevel.Fatal:
+ return LogEventLevel.Fatal;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(level), level, null);
+ }
+ }
+ }
+}
diff --git a/VocaluxeLib/Log/Rolling/CLogFileRoller.cs b/VocaluxeLib/Log/Rolling/CLogFileRoller.cs
index eed3ccdd..e417d6d0 100644
--- a/VocaluxeLib/Log/Rolling/CLogFileRoller.cs
+++ b/VocaluxeLib/Log/Rolling/CLogFileRoller.cs
@@ -73,7 +73,7 @@ namespace VocaluxeLib.Log.Rolling
private static void _DeleteOldLogs(string mainLogFile, int numLogsToKeep)
{
- Regex r = new Regex($"{Path.GetDirectoryName(mainLogFile)}\\{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(mainLogFile)}_([0-9]+){Path.GetExtension(mainLogFile)}", RegexOptions.IgnoreCase);
+ Regex r = new Regex($"{Regex.Escape(Path.GetDirectoryName(mainLogFile)??"")}\\{Path.DirectorySeparatorChar}{Regex.Escape(Path.GetFileNameWithoutExtension(mainLogFile)??"")}_([0-9]+){Path.GetExtension(mainLogFile)}", RegexOptions.IgnoreCase);
IEnumerable logFiles = Directory.EnumerateFiles($"{Path.GetDirectoryName(mainLogFile)}", $"{Path.GetFileNameWithoutExtension(mainLogFile)}*{Path.GetExtension(mainLogFile)}");
foreach (string file in logFiles)
{
diff --git a/VocaluxeLib/Properties/AssemblyInfo.cs b/VocaluxeLib/Properties/AssemblyInfo.cs
index 60e2dc45..019205d7 100644
--- a/VocaluxeLib/Properties/AssemblyInfo.cs
+++ b/VocaluxeLib/Properties/AssemblyInfo.cs
@@ -16,6 +16,7 @@
#endregion
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
@@ -53,4 +54,7 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+// Allow internal access from the Tests project
+[assembly: InternalsVisibleTo("Tests")]
\ No newline at end of file
diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj
index 5172700f..242ea280 100644
--- a/VocaluxeLib/VocaluxeLib.csproj
+++ b/VocaluxeLib/VocaluxeLib.csproj
@@ -112,6 +112,7 @@
+
diff --git a/VocaluxeTests/CTestHelpers.cs b/VocaluxeTests/CTestHelpers.cs
deleted file mode 100644
index 4ad00bf3..00000000
--- a/VocaluxeTests/CTestHelpers.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace VocaluxeTests
-{
- static class CTestHelpers
- {
- public static void AssertFail(Action test) where T : Exception
- {
- try
- {
- test.Invoke();
- Assert.Fail("Exception " + typeof(T).Name + " not thrown!");
- }
- catch (Exception e)
- {
- Assert.IsInstanceOfType(e, typeof(T));
- }
- }
- }
-}
\ No newline at end of file
diff --git a/VocaluxeTests/PartyModeTests.cs b/VocaluxeTests/PartyModeTests.cs
deleted file mode 100644
index e5c1eda6..00000000
--- a/VocaluxeTests/PartyModeTests.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Vocaluxe.Base;
-using Vocaluxe.Reporting;
-using VocaluxeLib;
-using VocaluxeLib.Log;
-using VocaluxeLib.PartyModes.Challenge;
-
-namespace VocaluxeTests
-{
- [TestClass]
- public class CPartyModeTests
- {
- [TestMethod]
- public void TestRoundBoundaries()
- {
- // ReSharper disable ObjectCreationAsStatement
- new CChallengeRounds(1, 1, 1); // Should succeed
- // ReSharper restore ObjectCreationAsStatement
- for (int inv = -1; inv <= 0; inv++)
- {
- int invL = inv;
- CTestHelpers.AssertFail(() => new CChallengeRounds(invL, 1, 1));
- CTestHelpers.AssertFail(() => new CChallengeRounds(1, invL, 1));
- CTestHelpers.AssertFail(() => new CChallengeRounds(1, 1, invL));
- }
- }
-
- private static void _CheckRounds(CChallengeRounds rounds, int numPlayer)
- {
- List numSongs = new List(numPlayer);
- for (int i = 0; i < numPlayer; i++)
- numSongs.Add(0);
- for (int i = 0; i < rounds.Count; i++)
- {
- foreach (int player in rounds[i].Players)
- {
- Assert.IsTrue(player >= 0 && player < numPlayer);
- numSongs[player]++;
- }
- }
- Assert.IsTrue(numSongs.Min() == numSongs.Max(), "Some players have more songs than others");
- }
-
- [TestMethod]
- public void TestRoundGeneration()
- {
- CBase.Game = new CBGame();
- CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc);
- for (int i = 0; i < 10; i++)
- {
- for (int numPlayer = 1; numPlayer <= 20; numPlayer++)
- {
- for (int numMic = 1; numMic <= 6; numMic++)
- {
- int roundFactor = (numPlayer % numMic == 0) ? numPlayer / numMic : numPlayer;
- for (int numRounds = roundFactor; numRounds <= 100 && numRounds <= roundFactor * 5; numRounds += roundFactor)
- {
- CChallengeRounds rounds = new CChallengeRounds(numRounds, numPlayer, numMic);
- Assert.IsTrue(rounds.Count >= numRounds);
- _CheckRounds(rounds, numPlayer);
- if (rounds.Count != numRounds)
- CLog.Debug("Number of rounds does not match. Expected: " + numRounds + ", Is: " + rounds.Count + " for " + numPlayer + "/" +
- ((numPlayer < numMic) ? numPlayer : numMic));
- }
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/VocaluxeTests/Properties/AssemblyInfo.cs b/VocaluxeTests/Properties/AssemblyInfo.cs
deleted file mode 100644
index 6001c0da..00000000
--- a/VocaluxeTests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// Allgemeine Informationen über eine Assembly werden über folgende
-// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
-// die einer Assembly zugeordnet sind.
-
-[assembly: AssemblyTitle("VocaluxeTests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("VocaluxeTests")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Wenn ComVisible auf "false" festgelegt wird, sind die Typen innerhalb dieser Assembly
-// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
-// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
-
-[assembly: ComVisible(false)]
-
-// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
-
-[assembly: Guid("3bdc6da5-a651-452e-903c-deec310288ad")]
-
-// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
-//
-// Hauptversion
-// Nebenversion
-// Buildnummer
-// Revision
-//
-// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
-// durch Einsatz von '*', wie in nachfolgendem Beispiel:
-// [Assembly: AssemblyVersion("1.0.*")]
-
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/VocaluxeTests/TestXmlFiles/SConfig.xml b/VocaluxeTests/TestXmlFiles/SConfig.xml
deleted file mode 100644
index c2258062..00000000
--- a/VocaluxeTests/TestXmlFiles/SConfig.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
- TR_CONFIG_LEVEL_MAX
- TR_CONFIG_ON
-
-
- TR_CONFIG_DIRECT3D
- TR_CONFIG_TEXTURE_HIGH
- 128
- 1024
- 576
- Middle
- 0
- 1
- 0
- 0
- X0
- 60
- TR_CONFIG_ON
- TR_CONFIG_OFF
- 0.4
-
-
- Ambient
- Blue
- Blue
- TR_CONFIG_ON
- TR_CONFIG_ON
- TR_CONFIG_TIMERLOOK_EXPANDED
- TR_CONFIG_PLAYERINFO_BOTH
- TR_CONFIG_FADEPLAYERINFO_OFF
- TR_CONFIG_COVERLOADING_ATSTART
- Slide
-
-
- GstreamerSharp
- PortAudio
- B2048
- 0
- TR_CONFIG_ON
- 20
- TR_CONFIG_NO_OWN_MUSIC
- TR_CONFIG_ON
- 50
- 100
-
-
- Deutsch
- E:\Songs
- TR_CONFIG_TILE_BOARD
- TR_CONFIG_ARTIST_LETTER
- TR_CONFIG_ON
- 10
- TR_CONFIG_TIMERMODE_REMAINING
- 1
- TR_CONFIG_ON
- TR_CONFIG_LYRICSPOSITION_BOTTOM
- 0.1
-
- guest1.xml
- guest1.xml
- guest1.xml
- guest1.xml
-
-
-
-
-
-
-
- Mikrofon (C-Media USB Headphone Set )
- Mikrofon (C-Media USB Headphone Set )6
- 1
-
- 120
-
-
- TR_CONFIG_ON
- TR_CONFIG_ON
- 3000
-
-
\ No newline at end of file
diff --git a/VocaluxeTests/VocaluxeTests.csproj b/VocaluxeTests/VocaluxeTests.csproj
deleted file mode 100644
index 772672eb..00000000
--- a/VocaluxeTests/VocaluxeTests.csproj
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
- Debug
- AnyCPU
- {93356718-3A0B-4784-AAE1-215065BFFC66}
- Library
- Properties
- VocaluxeTests
- VocaluxeTests
- v4.7.1
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 10.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
-
-
-
- true
- bin\x64\Debug\
- TRACE;DEBUG
- full
- x64
- prompt
- MinimumRecommendedRules.ruleset
-
-
- bin\x64\Release\
- TRACE
- true
- pdbonly
- x64
- prompt
- MinimumRecommendedRules.ruleset
-
-
- true
- bin\x86\Debug\
- DEBUG;TRACE
- full
- x86
- prompt
- MinimumRecommendedRules.ruleset
-
-
- bin\x86\Release\
- TRACE
- true
- pdbonly
- x86
- prompt
- MinimumRecommendedRules.ruleset
-
-
-
-
-
- False
- ..\Output\libs\managed\VocaluxeLib.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {5a4053f1-5ad5-441f-b254-d97a088127b6}
- PartyModeChallenge
-
-
- {2a1e0f2d-5392-4bb7-b0a1-a9dfa13e79ff}
- Vocaluxe
-
-
-
-
-
-
- False
-
-
- False
-
-
- False
-
-
- False
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
index 24586769..deca340e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -10,6 +10,8 @@ clone_depth: 15
environment:
GitHubKey:
secure: JSlN/em0JdspVn8jwaQ4IjugY6OQi0au4Qq0rhctJmcfGMaEGnUAOmDFULI48REW
+init:
+- git config --global core.autocrlf true
install:
- ps: |
$Env:CurrentCommitSha = "$(git rev-parse --verify HEAD)"
@@ -79,7 +81,6 @@ after_build:
.\.appveyor\nightlyDetect.ps1
.\.appveyor\moveTagForSpecialBranches.ps1
}
-test: off
before_deploy:
- ps: ./.appveyor/prepareDeploy.ps1
after_deploy: