public void AddCheck_ShouldAddCheckOnlyOnce_WhenSameCheckAddedMultipleTimes(IHealthCheck check) { HealthMonitor.AddCheck(check).Should().BeTrue(); HealthMonitor.AddCheck(check).Should().BeFalse(); HealthMonitor.AddCheck(check).Should().BeFalse(); HealthMonitor.AddCheck(check).Should().BeFalse(); HealthMonitor.Checks.Count.Should().Be(1); }
public async void Tick_ShouldNotCallHealthCheck_WhenItDoesNotNeedToRun(IHealthCheck check) { check.NeedsToRun.Returns(false); HealthMonitor.AddCheck(check).Should().BeTrue(); HealthMonitor.Tick(); // wait for the queue to run await Task.Delay(5); check.DidNotReceive().RunAsync(); }
internal static void Main(string[] args) { // Initialize the logger from app.config settings Log.Logger = new LoggerConfiguration().ReadFrom.AppSettings().Enrich.WithThreadId().CreateLogger(); // Create healthcheck that uses a ClusterManager based on app.config username/password // This will cause monitoring failure alerts if no valid config is present HealthMonitor.AddCheck(new BucketsHealthCheck()); HealthMonitor.AddCheck(new ClusterHealthCheck()); HealthMonitor.AddCheck(new PingHealthCheck()); // Add a logging notifier which, by default, logs the results to console as json HealthMonitor.AddNotifier(LibLogNotifierSettings.Create().ToNotifier()); // Start the ticking loop HealthMonitor.StartTicking(); // "press any key to stop" Console.ReadKey(); }
public void AddCheck_ShouldAddCheck(IHealthCheck check) { HealthMonitor.AddCheck(check).Should().BeTrue(); HealthMonitor.Checks.Count.Should().Be(1); }