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"); }
private static void _CloseProgram() { // Unloading in reverse order try { CController.Close(); CVocaluxeServer.Close(); CGraphics.Close(); CThemes.Close(); CCover.Close(); CFonts.Close(); CBackgroundMusic.Close(); CWebcam.Close(); CDataBase.Close(); CVideo.Close(); CRecord.Close(); CSound.Close(); CDraw.Close(); } catch (Exception e) { CLog.LogError("Error during shutdown!", false, false, e); } GC.Collect(); // Do a GC run here before we close logs to have finalizers run try { CLog.Close(); // Do this last, so we get all log entries! } catch (Exception) {} Environment.Exit(Environment.ExitCode); }