public void Single_average_is_fine() { JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, _logManager); localStats.ReportCall("A", 100, true); MakeTimePass(); localStats.ReportCall("A", 300, true); CheckLogLine("A|1|100|100|0|0|0|"); CheckLogLine("TOTAL|1|100|100|0|0|0|"); }
public void Orders_alphabetically() { JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, _logManager); localStats.ReportCall("C", 1, true); localStats.ReportCall("A", 2, true); localStats.ReportCall("B", 3, false); MakeTimePass(); localStats.ReportCall("A", 300, true); _testLogger.LogList[0].IndexOf("A ", StringComparison.InvariantCulture).Should().BeLessThan(_testLogger.LogList[0].IndexOf("B ", StringComparison.InvariantCulture)); _testLogger.LogList[0].IndexOf("B ", StringComparison.InvariantCulture).Should().BeLessThan(_testLogger.LogList[0].IndexOf("C ", StringComparison.InvariantCulture)); }
public void Does_not_report_when_info_not_enabled() { _testLogger = new TestLogger(); _testLogger.IsInfo = false; OneLoggerLogManager logManager = new OneLoggerLogManager(_testLogger); JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, logManager); localStats.ReportCall("A", 100, true); MakeTimePass(); localStats.ReportCall("A", 300, true); _testLogger.LogList.Should().HaveCount(0); }
public void Single_of_each_is_fine() { JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, _logManager); localStats.ReportCall("A", 25, true); localStats.ReportCall("A", 125, false); localStats.ReportCall("B", 75, true); localStats.ReportCall("B", 175, false); MakeTimePass(); localStats.ReportCall("A", 300, true); CheckLogLine("A|1|25|25|1|125|125|"); CheckLogLine("B|1|75|75|1|175|175|"); CheckLogLine("TOTAL|2|50|75|2|150|175|"); }
public void Does_not_report_when_nothing_to_report() { JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, _logManager); MakeTimePass(); localStats.ReportCall("A", 300, true); _testLogger.LogList.Should().HaveCount(0); }
public void Swaps_properly() { JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, _logManager); localStats.ReportCall("A", 100, true); MakeTimePass(); localStats.ReportCall("A", 300, true); CheckLogLine("A|1|100|100|0|0|0|"); _testLogger.LogList.Clear(); MakeTimePass(); localStats.ReportCall("A", 500, true); CheckLogLine("A|1|300|300|0|0|0|"); _testLogger.LogList.Clear(); MakeTimePass(); localStats.ReportCall("A", 700, true); CheckLogLine("A|1|500|500|0|0|0|"); _testLogger.LogList.Clear(); }
public void Calls_do_not_delay_report() { JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, _logManager); for (int i = 0; i < 100; i++) { localStats.ReportCall("A", 300, true); MakeTimePass(60); } _testLogger.LogList.Should().HaveCountGreaterThan(0); }
public void Multiple_have_no_decimal_places() { JsonRpcLocalStats localStats = new JsonRpcLocalStats(_manualTimestamper, _config, _logManager); localStats.ReportCall("A", 30, true); localStats.ReportCall("A", 20, true); localStats.ReportCall("A", 50, true); localStats.ReportCall("A", 60, false); localStats.ReportCall("A", 40, false); localStats.ReportCall("A", 100, false); MakeTimePass(); localStats.ReportCall("A", 300, true); CheckLogLine("A|3|33|50|3|67|100|"); CheckLogLine("TOTAL|3|33|50|3|67|100|"); }