public void TestGetErrorPercentage() { var config = GetCommandConfig(); ICommandMetrics metrics = GetMetrics(config); metrics.MarkSuccess(1000); Thread.Sleep(config.MetricsHealthSnapshotIntervalInMilliseconds); Assert.AreEqual(0, metrics.GetErrorPercentage()); metrics.MarkFailure(); Thread.Sleep(config.MetricsHealthSnapshotIntervalInMilliseconds); Assert.AreEqual(50, metrics.GetErrorPercentage()); metrics.MarkSuccess(100); metrics.MarkSuccess(100); Thread.Sleep(config.MetricsHealthSnapshotIntervalInMilliseconds); Assert.AreEqual(25, metrics.GetErrorPercentage()); metrics.MarkTimeout(5000); metrics.MarkTimeout(5000); Thread.Sleep(config.MetricsHealthSnapshotIntervalInMilliseconds); Assert.AreEqual(50, metrics.GetErrorPercentage()); metrics.MarkSuccess(100); metrics.MarkSuccess(100); metrics.MarkSuccess(100); // latent Thread.Sleep(config.MetricsHealthSnapshotIntervalInMilliseconds); metrics.MarkSuccess(5000); Thread.Sleep(config.MetricsHealthSnapshotIntervalInMilliseconds); // 6 success + 1 latent success + 1 failure + 2 timeout = 10 total // latent success not considered error // error percentage = 1 failure + 2 timeout / 10 Assert.AreEqual(30, metrics.GetErrorPercentage()); }