Merge pull request #385 from lukeIam/testing

Tests for Vocaluxe
This commit is contained in:
Florian Küpper authored and GitHub committed 2018-04-02 11:30:26 +02:00
commit ba1a3ab7d0
37 files changed
+2358 -638

No files matched your search

+2 -1
View File
@@ -71,4 +71,5 @@ tx.exe
/Output/x86
/PitchTracker/bin
/PitchTracker/obj
/Logs
/Logs
/Tests/bin
@@ -87,6 +87,7 @@
<Compile Include="CPartyScreenChallengeConfig.cs" />
<Compile Include="CPartyScreenChallengeMain.cs" />
<Compile Include="CPartyScreenChallengeNames.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VocaluxeLib\VocaluxeLib.csproj">
@@ -99,9 +100,7 @@
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">if exist "$(SolutionDir)Output\PartyModes\$(TargetName)\Code" rd "$(SolutionDir)Output\PartyModes\$(TargetName)\Code" /S /Q
@@ -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 <http://www.gnu.org/licenses/>.
#endregion
using System.Runtime.CompilerServices;
// Allow internal access from the Tests project
[assembly: InternalsVisibleTo("Tests")]
@@ -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 <http://www.gnu.org/licenses/>.
#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<ArgumentException>(() => new CChallengeRounds(invL, 1, 1));
Assert.Throws<ArgumentException>(() => new CChallengeRounds(1, invL, 1));
Assert.Throws<ArgumentException>(() => 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<int> numSongs = new List<int>(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
}
}
+33
View File
@@ -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")]
+130
View File
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.10.1\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.10.1\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{8EDF4429-251A-416D-BB68-93F227191BCF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.10.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PartyModeChallenge\CPartyModeChallangeTest.cs" />
<Content Include="VocaluxeLib\Log\CLogTest.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>CLogTest.cs</LastGenOutput>
</Content>
<Compile Include="VocaluxeLib\Log\CBenchmarkTest.cs" />
<Compile Include="VocaluxeLib\Log\CLogTest.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>CLogTest.tt</DependentUpon>
</Compile>
<Compile Include="VocaluxeLib\Log\Rolling\CLogFileRollerTest.cs" />
<Compile Include="VocaluxeLib\Utils\Combinatorics\CCombinationsTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VocaluxeLib\XML\CXmlSerializerTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PartyModes\PartyModeChallenge\PartyModeChallenge.csproj">
<Project>{5a4053f1-5ad5-441f-b254-d97a088127b6}</Project>
<Name>PartyModeChallenge</Name>
</ProjectReference>
<ProjectReference Include="..\VocaluxeLib\VocaluxeLib.csproj">
<Project>{D2B6DDEF-E0E1-4DDF-A73A-E6ACEF5C95EC}</Project>
<Name>VocaluxeLib</Name>
</ProjectReference>
<ProjectReference Include="..\Vocaluxe\Vocaluxe.csproj">
<Project>{2a1e0f2d-5392-4bb7-b0a1-a9dfa13e79ff}</Project>
<Name>Vocaluxe</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="VocaluxeLib\XML\TestFiles\Dictionary`2.xml" />
<Content Include="VocaluxeLib\XML\TestFiles\SConfig.xml" />
<Content Include="VocaluxeLib\XML\TestFiles\SDefaultFonts.xml" />
<Content Include="VocaluxeLib\XML\TestFiles\SSkin.xml" />
<Content Include="VocaluxeLib\XML\TestFiles\STheme.xml" />
<Content Include="VocaluxeLib\XML\TestFiles\SThemeCover.xml" />
<Content Include="VocaluxeLib\XML\TestFiles\SThemeScreen.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit.3.10.1\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.10.1\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.10.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+164
View File
@@ -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 <http://www.gnu.org/licenses/>.
#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
}
}
File diff suppressed because it is too large. Load diff
+161
View File
@@ -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 <http://www.gnu.org/licenses/>.
#>
<#@ 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 <http://www.gnu.org/licenses/>.
#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
}
}
@@ -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 <http://www.gnu.org/licenses/>.
#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
}
}
@@ -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 <http://www.gnu.org/licenses/>.
#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<int>.Count(4, 3));
Assert.AreEqual(6, CCombinations<int>.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<int>.Count(12, i), CCombinations<int>.Count(12, 12 - i));
CTestHelpers.AssertFail<ArgumentException>(() => CCombinations<int>.Count(-1, -1));
CTestHelpers.AssertFail<ArgumentException>(() => CCombinations<int>.Count(-1, 1));
CTestHelpers.AssertFail<ArgumentException>(() => CCombinations<int>.Count(1, -1));
Assert.That(() => CCombinations<int>.Count(-1, -1), Throws.TypeOf<ArgumentException>());
Assert.That(() => CCombinations<int>.Count(-1, 1), Throws.TypeOf<ArgumentException>());
Assert.That(() => CCombinations<int>.Count(1, -1), Throws.TypeOf<ArgumentException>());
}
[Test]
public void TestResults([Range(0, 8, 1)] int n)
{
Random rand = new Random();
for (int k = 0; k <= n; k++)
{
List<int> collection = new List<int>(n);
int r = rand.Next(1000);
for (int i = 0; i < n; i++)
collection.Add(i + r);
CCombinations<int> combs = new CCombinations<int>(collection, k);
Assert.AreEqual(CCombinations<int>.Count(n, k), combs.Count());
_CheckResults(combs, collection);
}
}
#endregion
#region Helper methods
// ReSharper disable UnusedParameter.Local
private static void _CheckResults<T>(CCombinations<T> combs, List<T> input)
// ReSharper restore UnusedParameter.Local
// ReSharper restore UnusedParameter.Local
{
List<List<T>> results = new List<List<T>>();
foreach (List<T> comb in combs)
@@ -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<int> collection = new List<int>(n);
int r = rand.Next(1000);
for (int i = 0; i < n; i++)
collection.Add(i + r);
CCombinations<int> combs = new CCombinations<int>(collection, k);
Assert.AreEqual(CCombinations<int>.Count(n, k), combs.Count());
_CheckResults(combs, collection);
}
}
}
#endregion
}
}
}
@@ -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 <http://www.gnu.org/licenses/>.
#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 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
private const string _Empty = _Head + @"<root />";
#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<SEntry> Ints;
}
private struct SArray
{
[XmlArray] public SEntry[] Ints;
}
private struct SListEmb
{
public int I;
[XmlElement("Entry")] public List<SEntry> 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<T, T2>(String xmlString) where T2 : Exception where T : new()
{
var deserializer = new CXmlDeserializer();
CTestHelpers.AssertFail<T2>(() => deserializer.DeserializeString<T>(xmlString));
}
private static T _AssertSerDeserMatch<T>(string xmlString) where T : new()
{
var deserializer = new CXmlDeserializer();
var serializer = new CXmlSerializer();
T foo = deserializer.DeserializeString<T>(xmlString);
string xmlNew = serializer.Serialize(foo);
Assert.AreEqual(xmlString, xmlNew);
return foo;
}
[TestMethod]
[Test]
public void TestBasic()
{
const string s = @"<root>
@@ -150,10 +63,10 @@ namespace VocaluxeTests
Assert.AreEqual(4, foo.D, 0.0001);
}
[TestMethod]
[Test]
public void TestMissingXmlElement()
{
string[] s = new string[] {@"<root>
string[] s = new string[] { @"<root>
<S>2</S>
<F>3</F>
<D>4</D>
@@ -165,7 +78,7 @@ namespace VocaluxeTests
<I>1</I>
<S>2</S>
<F>3</F>
</root>"};
</root>" };
foreach (string s1 in s)
{
string sTmp = s1;
@@ -173,10 +86,10 @@ namespace VocaluxeTests
}
}
[TestMethod]
[Test]
public void TestMissingStructElement()
{
string[] s = new string[] {@"<root>
string[] s = new string[] { @"<root>
<Foo>1</Foo>
<I>1</I>
<S>2</S>
@@ -194,7 +107,7 @@ namespace VocaluxeTests
<F>3</F>
<D>4</D>
<Foo>1</Foo>
</root>"};
</root>" };
foreach (string s1 in s)
{
string sTmp = s1;
@@ -202,7 +115,7 @@ namespace VocaluxeTests
}
}
[TestMethod]
[Test]
public void TestBasicSerialization()
{
const string s = _Head + @"<root>
@@ -235,7 +148,7 @@ namespace VocaluxeTests
</root>"
};
[TestMethod]
[Test]
public void TestList()
{
var xml = new CXmlDeserializer();
@@ -258,7 +171,7 @@ namespace VocaluxeTests
_AssertFail<SList, CXmlException>(_Empty);
}
[TestMethod]
[Test]
public void TestArray()
{
var xml = new CXmlDeserializer();
@@ -307,7 +220,7 @@ namespace VocaluxeTests
<J>3</J>
</root>";
[TestMethod]
[Test]
public void TestListEmbedded()
{
var xml = new CXmlDeserializer();
@@ -333,7 +246,7 @@ namespace VocaluxeTests
_AssertFail<SListEmb, CXmlException>(_Empty);
}
[TestMethod]
[Test]
public void TestArrayEmbedded()
{
var xml = new CXmlDeserializer();
@@ -359,7 +272,7 @@ namespace VocaluxeTests
_AssertFail<SArrayEmb, CXmlException>(_Empty);
}
[TestMethod]
[Test]
public void TestProperty()
{
const string xmlString = _Head + @"<root>
@@ -371,7 +284,7 @@ namespace VocaluxeTests
Assert.AreEqual(3, foo.Auto);
}
[TestMethod]
[Test]
public void TestByteArray()
{
const string xmlString = _Head + @"<root>
@@ -388,31 +301,31 @@ namespace VocaluxeTests
<J>2</J>
</root>";
[TestMethod]
[Test]
public void TestIgnore()
{
_AssertSerDeserMatch<SIgnore>(_XmlIgnore);
_AssertFail<SIgnore, CXmlException>(_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 + @"<root>
@@ -422,7 +335,7 @@ namespace VocaluxeTests
_AssertSerDeserMatch<List<string>>(s);
}
[TestMethod]
[Test]
public void TestOnlyDict()
{
const string s = _Head + @"<root>
@@ -432,7 +345,7 @@ namespace VocaluxeTests
_AssertSerDeserMatch<Dictionary<string, string>>(s);
}
[TestMethod]
[Test]
public void TestDefaultValues()
{
const string s = _Head + @"<root>
@@ -458,33 +371,148 @@ namespace VocaluxeTests
</root>", 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<string, string>))] Type type)
{
Type[] types = new Type[]
{typeof(SThemeCover), typeof(CConfig.SConfig), typeof(SThemeScreen), typeof(SDefaultFonts), typeof(SSkin), typeof(STheme), typeof(Dictionary<string, string>)};
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<string, string>) ? "resources" : null);
// Typename will be uppercase but input is lowercase
newXml = newXml.Replace("<String", "<string").Replace("</String", "</string");
string oldXml = File.ReadAllText(xmlPath);
Assert.AreEqual(oldXml, newXml, "Error with " + type.Name);
}
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "VocaluxeLib", "XML", "TestFiles");
string xmlPath = Path.Combine(filePath, type.Name + ".xml");
var deser = new CXmlDeserializer();
object foo = deser.Deserialize(xmlPath, Activator.CreateInstance(type));
Assert.IsInstanceOf(type, foo, "Wrong type with " + type.Name);
var ser = new CXmlSerializer(type == typeof(CConfig.SConfig));
string newXml = ser.Serialize(foo, type == typeof(Dictionary<string, string>) ? "resources" : null);
// Typename will be uppercase but input is lowercase
newXml = newXml.Replace("<String", "<string").Replace("</String", "</string");
string oldXml = File.ReadAllText(xmlPath);
Assert.AreEqual(oldXml, newXml, "Recontructed XML has differences.");
}
#endregion
#region Helper
#pragma warning disable 649
#pragma warning disable 169
private struct SBasic
{
public int I;
public string S;
public float F;
public double D;
}
[XmlType("Entry")]
private struct SEntry
{
public int I;
}
private struct SList
{
[XmlArray]
public List<SEntry> Ints;
}
private struct SArray
{
[XmlArray]
public SEntry[] Ints;
}
private struct SListEmb
{
public int I;
[XmlElement("Entry")]
public List<SEntry> 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<T, T2>(String xmlString) where T2 : Exception where T : new()
{
var deserializer = new CXmlDeserializer();
Exception exception =
Assert.Catch(() => deserializer.DeserializeString<T>(xmlString));
Assert.IsInstanceOf(typeof(T2), exception);
}
private static T _AssertSerDeserMatch<T>(string xmlString) where T : new()
{
var deserializer = new CXmlDeserializer();
var serializer = new CXmlSerializer();
T foo = deserializer.DeserializeString<T>(xmlString);
string xmlNew = serializer.Serialize(foo);
Assert.AreEqual(xmlString, xmlNew);
return foo;
}
#endregion
}
}
}
+133
View File
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<Info>
<Version>Vocaluxe 'Blue Sunrise' 0.4.0 (x64) (0.4.0-261-gd0c81b4d9)</Version>
<Time>23.03.2018 14:17:29</Time>
<Platform>Win32NT</Platform>
<OSVersion>Microsoft Windows NT 6.2.9200.0</OSVersion>
<ProcessorCount>4</ProcessorCount>
<Screens>2</Screens>
<PrimaryScreenResolution>{Width=1920, Height=1080}</PrimaryScreenResolution>
<Directory>D:\Vocaluxe\</Directory>
</Info>
<Debug>
<DebugLevel>TR_CONFIG_OFF</DebugLevel>
<SaveModifiedSongs>TR_CONFIG_OFF</SaveModifiedSongs>
</Debug>
<Graphics>
<Renderer>TR_CONFIG_DIRECT3D</Renderer>
<TextureQuality>TR_CONFIG_TEXTURE_MEDIUM</TextureQuality>
<CoverSize>256</CoverSize>
<NumScreens>1</NumScreens>
<ScreenW>1024</ScreenW>
<ScreenH>576</ScreenH>
<ScreenAlignment>Middle</ScreenAlignment>
<BorderLeft>0</BorderLeft>
<BorderRight>0</BorderRight>
<BorderTop>0</BorderTop>
<BorderBottom>0</BorderBottom>
<AAMode>X0</AAMode>
<MaxFPS>60</MaxFPS>
<VSync>TR_CONFIG_ON</VSync>
<FullScreen>TR_CONFIG_ON</FullScreen>
<Stretch>TR_CONFIG_OFF</Stretch>
<FadeTime>0.4</FadeTime>
</Graphics>
<Theme>
<Name>Genius</Name>
<Skin>Standard</Skin>
<Cover>Genius Standard</Cover>
<DrawNoteLines>TR_CONFIG_ON</DrawNoteLines>
<DrawToneHelper>TR_CONFIG_ON</DrawToneHelper>
<TimerLook>TR_CONFIG_TIMERLOOK_EXPANDED</TimerLook>
<PlayerInfo>TR_CONFIG_PLAYERINFO_BOTH</PlayerInfo>
<FadePlayerInfo>TR_CONFIG_FADEPLAYERINFO_OFF</FadePlayerInfo>
<CoverLoading>TR_CONFIG_COVERLOADING_DYNAMIC</CoverLoading>
<LyricStyle>TR_CONFIG_LYRICSTYLE_SLIDE</LyricStyle>
</Theme>
<Sound>
<PlayBackLib>GstreamerSharp</PlayBackLib>
<RecordLib>PortAudio</RecordLib>
<AudioBufferSize>B2048</AudioBufferSize>
<AudioLatency>0</AudioLatency>
<BackgroundMusic>TR_CONFIG_ON</BackgroundMusic>
<BackgroundMusicVolume>30</BackgroundMusicVolume>
<BackgroundMusicSource>TR_CONFIG_NO_OWN_MUSIC</BackgroundMusicSource>
<BackgroundMusicUseStart>TR_CONFIG_ON</BackgroundMusicUseStart>
<PreviewMusicVolume>50</PreviewMusicVolume>
<GameMusicVolume>80</GameMusicVolume>
<KaraokeEffect>TR_CONFIG_OFF</KaraokeEffect>
<KaraokeEffectLevel>1</KaraokeEffectLevel>
</Sound>
<Game>
<Language>English</Language>
<SongFolder>D:\Vocaluxe\Songs</SongFolder>
<SongMenu>TR_CONFIG_TILE_BOARD</SongMenu>
<SongSorting>TR_CONFIG_ARTIST</SongSorting>
<IgnoreArticles>TR_CONFIG_ON</IgnoreArticles>
<TimerMode>TR_CONFIG_TIMERMODE_REMAINING</TimerMode>
<NumPlayers>2</NumPlayers>
<Tabs>TR_CONFIG_OFF</Tabs>
<AutoplayPreviews>TR_CONFIG_OFF</AutoplayPreviews>
<AutoplayPreviewDelay>500</AutoplayPreviewDelay>
<LyricsPosition>TR_CONFIG_LYRICSPOSITION_BOTTOM</LyricsPosition>
<MinLineBreakTime>0.1</MinLineBreakTime>
<Players>
<Player />
<Player />
<Player />
<Player />
<Player />
<Player />
</Players>
<HighscoreStyle>TR_CONFIG_HIGHSCORE_LIST_BEST</HighscoreStyle>
</Game>
<Video>
<VideoDecoder>FFmpeg</VideoDecoder>
<VideoBackgrounds>TR_CONFIG_ON</VideoBackgrounds>
<VideoPreview>TR_CONFIG_ON</VideoPreview>
<VideosInSongs>TR_CONFIG_ON</VideosInSongs>
<VideosToBackground>TR_CONFIG_OFF</VideosToBackground>
<WebcamLib>AForgeNet</WebcamLib>
<WebcamConfig />
</Video>
<Record>
<MicConfig>
<DeviceName />
<DeviceDriver />
<Channel>0</Channel>
</MicConfig>
<MicConfig>
<DeviceName />
<DeviceDriver />
<Channel>0</Channel>
</MicConfig>
<MicConfig>
<DeviceName />
<DeviceDriver />
<Channel>0</Channel>
</MicConfig>
<MicConfig>
<DeviceName />
<DeviceDriver />
<Channel>0</Channel>
</MicConfig>
<MicConfig>
<DeviceName />
<DeviceDriver />
<Channel>0</Channel>
</MicConfig>
<MicConfig>
<DeviceName />
<DeviceDriver />
<Channel>0</Channel>
</MicConfig>
<MicDelay>200</MicDelay>
</Record>
<Server>
<ServerActive>TR_CONFIG_OFF</ServerActive>
<ServerEncryption>TR_CONFIG_OFF</ServerEncryption>
<ServerPort>3000</ServerPort>
<SongCountCoverThreshold>70</SongCountCoverThreshold>
</Server>
</root>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Screen>
<Screen xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Informations>
<ScreenName>ScreenMain</ScreenName>
<ScreenVersion>2</ScreenVersion>
@@ -14,25 +14,14 @@
</Background>
</Backgrounds>
<Statics>
<Static Name="StaticMenuBar">
<Skin>Menu</Skin>
<Color Name="Invisible" />
<Rect>
<X>49</X>
<Y>32</Y>
<W>1181</W>
<H>50</H>
<Z>0</Z>
</Rect>
</Static>
<Static Name="StaticWarningProfiles">
<Skin>TextBG</Skin>
<Skin>Warning</Skin>
<Color Name="StaticWarningColor" />
<Rect>
<X>150</X>
<Y>610</Y>
<W>355</W>
<H>30</H>
<X>260</X>
<Y>310</Y>
<W>760</W>
<H>50</H>
<Z>-1.9</Z>
</Rect>
</Static>
@@ -40,7 +29,7 @@
<Texts>
<Text Name="TextRelease">
<X>10</X>
<Y>690</Y>
<Y>700</Y>
<Z>-1</Z>
<H>15</H>
<MaxW>0</MaxW>
@@ -53,11 +42,11 @@
<Text>Vocaluxe "Shining Heaven" v0.3.0 (x64) Beta (0083)</Text>
</Text>
<Text Name="TextWarningProfiles">
<X>320</X>
<Y>612</Y>
<X>640</X>
<Y>322</Y>
<Z>-2</Z>
<H>27</H>
<MaxW>355</MaxW>
<H>25</H>
<MaxW>640</MaxW>
<Color Name="TextWarningColor" />
<SelColor Name="TextWarningColor" />
<Align>Center</Align>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.10.1" targetFramework="net47" />
<package id="NUnit3TestAdapter" version="3.10.0" targetFramework="net47" />
</packages>
+23 -29
View File
@@ -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
+8
View File
@@ -29,7 +29,10 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ONLY_FOR_MULTILINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_USER_LINEBREAKS/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">ALWAYS</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_COMPLEX_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_EMBEDDED_STATEMENT_ON_SAME_LINE/@EntryValue">NEVER</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
@@ -117,7 +120,12 @@ along with $SOLUTION$. If not, see &lt;http://www.gnu.org/licenses/&gt;.</s:Stri
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=8cff90ce_002Def0d_002D436d_002Db8f2_002D5b5bdb923d3b/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Classes"&gt;&lt;ElementKinds&gt;&lt;Kind Name="CLASS" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="C" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=9aa707ae_002Dd4fb_002D4760_002Da649_002Dffcedfabd5dc/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected" Description="Fields (not public)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;Kind Name="METHOD" /&gt;&lt;Kind Name="PROPERTY" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=da335a8d_002D4b6e_002D4df6_002D8434_002D29ffe5e2547b/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private, Protected, ProtectedInternal, Internal, Public" Description="Structs"&gt;&lt;ElementKinds&gt;&lt;Kind Name="STRUCT" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="S" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/UnitTesting/DisabledProviders/=MSTest/@EntryIndexedValue">False</s:Boolean>
-28
View File
@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="VocaluxeTestSettings" id="58f74469-1437-4c0f-9142-c1ec6920c168" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>Dies sind die standardmäßigen Testeinstellungen für einen lokalen Testlauf.</Description>
<Deployment enabled="false" />
<Execution hostProcessPlatform="MSIL">
<Hosts skipUnhostableTests="false" />
<Timeouts runTimeout="1800000" testTimeout="120000" />
<TestTypeSpecific>
<UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
<WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
<Browser name="Internet Explorer 9.0" MaxConnections="6">
<Headers>
<Header name="User-Agent" value="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" />
<Header name="Accept" value="*/*" />
<Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
<Header name="Accept-Encoding" value="GZIP" />
</Headers>
</Browser>
</WebTestRunConfiguration>
</TestTypeSpecific>
<AgentRule name="LocalMachineDefaultRole">
</AgentRule>
</Execution>
</TestSettings>
+7 -1
View File
@@ -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;
+5
View File
@@ -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")]
+2 -2
View File
@@ -61,10 +61,10 @@ namespace VocaluxeLib.Log
/// Stops this benchmark.
/// </summary>
/// <param name="success">If true a success message will be added to the log otherwise a message for failure.</param>
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);
+24 -10
View File
@@ -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}";
/// <summary>
/// Initialize the logging framework.
/// </summary>
@@ -51,7 +50,8 @@ namespace VocaluxeLib.Log
/// <param name="fileNameCrashMarker">The name of the file which is used as crash marker.</param>
/// <param name="currentVersion">The current version tag as it is displayed in the main menu.</param>
/// <param name="showReporterFunc">Delegate to the function which should be called if the reporter have to been shown.</param>
public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc)
/// <param name="logLevel">The log level for log messages.</param>
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() } ) );
}
/// <summary>
@@ -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
+56
View File
@@ -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 <http://www.gnu.org/licenses/>.
#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);
}
}
}
}
+1 -1
View File
@@ -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<string> logFiles = Directory.EnumerateFiles($"{Path.GetDirectoryName(mainLogFile)}", $"{Path.GetFileNameWithoutExtension(mainLogFile)}*{Path.GetExtension(mainLogFile)}");
foreach (string file in logFiles)
{
+5 -1
View File
@@ -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")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// Allow internal access from the Tests project
[assembly: InternalsVisibleTo("Tests")]
+1
View File
@@ -112,6 +112,7 @@
<Compile Include="CEncoding.cs" />
<Compile Include="CFading.cs" />
<Compile Include="CFont.cs" />
<Compile Include="Log\ELogLevel.cs" />
<Compile Include="Log\ShowReporterDelegate.cs" />
<Compile Include="Log\CLog.cs" />
<Compile Include="CVideoStream.cs" />
-21
View File
@@ -1,21 +0,0 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace VocaluxeTests
{
static class CTestHelpers
{
public static void AssertFail<T>(Action test) where T : Exception
{
try
{
test.Invoke();
Assert.Fail("Exception " + typeof(T).Name + " not thrown!");
}
catch (Exception e)
{
Assert.IsInstanceOfType(e, typeof(T));
}
}
}
}
-73
View File
@@ -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<ArgumentException>(() => new CChallengeRounds(invL, 1, 1));
CTestHelpers.AssertFail<ArgumentException>(() => new CChallengeRounds(1, invL, 1));
CTestHelpers.AssertFail<ArgumentException>(() => new CChallengeRounds(1, 1, invL));
}
}
private static void _CheckRounds(CChallengeRounds rounds, int numPlayer)
{
List<int> numSongs = new List<int>(numPlayer);
for (int i = 0; i < numPlayer; i++)
numSongs.Add(0);
for (int i = 0; i < rounds.Count; i++)
{
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));
}
}
}
}
}
}
}
-39
View File
@@ -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")]
-97
View File
@@ -1,97 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<Info />
<Debug>
<DebugLevel>TR_CONFIG_LEVEL_MAX</DebugLevel>
<SaveModifiedSongs>TR_CONFIG_ON</SaveModifiedSongs>
</Debug>
<Graphics>
<Renderer>TR_CONFIG_DIRECT3D</Renderer>
<TextureQuality>TR_CONFIG_TEXTURE_HIGH</TextureQuality>
<CoverSize>128</CoverSize>
<ScreenW>1024</ScreenW>
<ScreenH>576</ScreenH>
<ScreenAlignment>Middle</ScreenAlignment>
<BorderLeft>0</BorderLeft>
<BorderRight>1</BorderRight>
<BorderTop>0</BorderTop>
<BorderBottom>0</BorderBottom>
<AAMode>X0</AAMode>
<MaxFPS>60</MaxFPS>
<VSync>TR_CONFIG_ON</VSync>
<FullScreen>TR_CONFIG_OFF</FullScreen>
<FadeTime>0.4</FadeTime>
</Graphics>
<Theme>
<Name>Ambient</Name>
<Skin>Blue</Skin>
<Cover>Blue</Cover>
<DrawNoteLines>TR_CONFIG_ON</DrawNoteLines>
<DrawToneHelper>TR_CONFIG_ON</DrawToneHelper>
<TimerLook>TR_CONFIG_TIMERLOOK_EXPANDED</TimerLook>
<PlayerInfo>TR_CONFIG_PLAYERINFO_BOTH</PlayerInfo>
<FadePlayerInfo>TR_CONFIG_FADEPLAYERINFO_OFF</FadePlayerInfo>
<CoverLoading>TR_CONFIG_COVERLOADING_ATSTART</CoverLoading>
<LyricStyle>Slide</LyricStyle>
</Theme>
<Sound>
<PlayBackLib>GstreamerSharp</PlayBackLib>
<RecordLib>PortAudio</RecordLib>
<AudioBufferSize>B2048</AudioBufferSize>
<AudioLatency>0</AudioLatency>
<BackgroundMusic>TR_CONFIG_ON</BackgroundMusic>
<BackgroundMusicVolume>20</BackgroundMusicVolume>
<BackgroundMusicSource>TR_CONFIG_NO_OWN_MUSIC</BackgroundMusicSource>
<BackgroundMusicUseStart>TR_CONFIG_ON</BackgroundMusicUseStart>
<PreviewMusicVolume>50</PreviewMusicVolume>
<GameMusicVolume>100</GameMusicVolume>
</Sound>
<Game>
<Language>Deutsch</Language>
<SongFolder>E:\Songs</SongFolder>
<SongMenu>TR_CONFIG_TILE_BOARD</SongMenu>
<SongSorting>TR_CONFIG_ARTIST_LETTER</SongSorting>
<IgnoreArticles>TR_CONFIG_ON</IgnoreArticles>
<ScoreAnimationTime>10</ScoreAnimationTime>
<TimerMode>TR_CONFIG_TIMERMODE_REMAINING</TimerMode>
<NumPlayers>1</NumPlayers>
<Tabs>TR_CONFIG_ON</Tabs>
<LyricsPosition>TR_CONFIG_LYRICSPOSITION_BOTTOM</LyricsPosition>
<MinLineBreakTime>0.1</MinLineBreakTime>
<Players>
<Player>guest1.xml</Player>
<Player>guest1.xml</Player>
<Player>guest1.xml</Player>
<Player>guest1.xml</Player>
<Player />
<Player />
</Players>
</Game>
<Video>
<VideoDecoder>FFmpeg</VideoDecoder>
<VideoBackgrounds>TR_CONFIG_ON</VideoBackgrounds>
<VideoPreview>TR_CONFIG_ON</VideoPreview>
<VideosInSongs>TR_CONFIG_ON</VideosInSongs>
<VideosToBackground>TR_CONFIG_ON</VideosToBackground>
<WebcamLib>OpenCV</WebcamLib>
<WebcamConfig>
<MonikerString />
<Framerate>0</Framerate>
<Width>0</Width>
<Height>0</Height>
</WebcamConfig>
</Video>
<Record>
<MicConfig>
<DeviceName>Mikrofon (C-Media USB Headphone Set )</DeviceName>
<DeviceDriver>Mikrofon (C-Media USB Headphone Set )6</DeviceDriver>
<Channel>1</Channel>
</MicConfig>
<MicDelay>120</MicDelay>
</Record>
<Server>
<ServerActive>TR_CONFIG_ON</ServerActive>
<ServerEncryption>TR_CONFIG_ON</ServerEncryption>
<ServerPort>3000</ServerPort>
</Server>
</root>
-121
View File
@@ -1,121 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{93356718-3A0B-4784-AAE1-215065BFFC66}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VocaluxeTests</RootNamespace>
<AssemblyName>VocaluxeTests</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.XML" />
<Reference Include="VocaluxeLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Output\libs\managed\VocaluxeLib.dll</HintPath>
</Reference>
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="CTestHelpers.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CombinatoricsTest.cs" />
<Compile Include="PartyModeTests.cs" />
<Compile Include="XmlSerializerTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PartyModes\PartyModeChallenge\PartyModeChallenge.csproj">
<Project>{5a4053f1-5ad5-441f-b254-d97a088127b6}</Project>
<Name>PartyModeChallenge</Name>
</ProjectReference>
<ProjectReference Include="..\Vocaluxe\Vocaluxe.csproj">
<Project>{2a1e0f2d-5392-4bb7-b0a1-a9dfa13e79ff}</Project>
<Name>Vocaluxe</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+2 -1
View File
@@ -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: