public void Start_WithNoHeartbeat_ThrowsArgumentNullException() { var client = new MockSensuClient(); _sut = new Pacemaker(client); Assert.Throws <ArgumentNullException>(() => _sut.Start(null)); }
public void Stop_WhenNotStarted_DoesNothing() { var client = new MockSensuClient(); _sut = new Pacemaker(client); _sut.Stop(); }
public void Start_WithValidHeartbeat_Sends1stMessageWithin5ms() { var client = new MockSensuClient(); _sut = new Pacemaker(client); _sut.Start(new Heartbeat("testApp")); Thread.Sleep(5); Assert.NotEmpty(client.Messages); }
public void Send_OnIHaveMeta_DoesCallEnrichMessage() { ISensuEnricher enricher = new HostInfoEnricher(); var sut = new MockSensuClient(); sut.EnrichWith(enricher); sut.Send(new Ok("app_name", "some_metric")); Assert.True(sut.Enriched); }
public void Send_OnNotIHaveMeta_DoesNotCallEnrichMessage() { ISensuEnricher enricher = new HostInfoEnricher(); var sut = new MockSensuClient(); sut.EnrichWith(enricher); sut.Send(new {}); Assert.False(sut.Enriched); }
public void Start_WithPeriodOf1sec_Sends2MessagesIn2sec() { var client = new MockSensuClient(); _sut = new Pacemaker(client); _sut.Start(new Heartbeat("testApp", 1)); Thread.Sleep(1900); _sut.Stop(); Assert.Equal(2, client.Messages.Count); }
public void Heartbeat_WithNoParameters_SendsHeartbeat() { var client = new MockSensuClient(); var sut = new SensuMonitor(client, "testApp"); sut.Heartbeat(); var message = client.Messages.First(); Assert.IsType <Heartbeat>(message); }
public void Error_WithNoParameters_SendsAppError() { var client = new MockSensuClient(); var sut = new SensuMonitor(client, "testApp"); sut.Error("some_dependency"); var message = client.Messages.First(); Assert.IsType <Error>(message); }
public void Heartbeat_WithPeriod5_SetsTtlTo5() { var client = new MockSensuClient(); var sut = new SensuMonitor(client, "testApp"); sut.Heartbeat(period: 5); var message = client.Messages.First() as Heartbeat; Assert.Equal(5, message.Ttl); }
public void Heartbeat_WithNoParameters_SetsTtlTo60() { var client = new MockSensuClient(); var sut = new SensuMonitor(client, "testApp"); sut.Heartbeat(); var message = client.Messages.First() as Heartbeat; Assert.Equal(60, message.Ttl); }
public void EnrichWith_WithAnEnricher_AddsEnricherToClient() { ISensuEnricher enricher = new HostInfoEnricher(); var sut = new MockSensuClient(); sut.EnrichWith(enricher); var enrichers = sut.GetEnrichers(); Assert.Contains(enricher, enrichers); }
public void Stop_WhileHeardbeatRunning_StopsHeartbeat() { var client = new MockSensuClient(); _sut = new Pacemaker(client); _sut.Start(new Heartbeat("testApp", 1)); Thread.Sleep(5); _sut.Stop(); Thread.Sleep(2000); Assert.Equal(1, client.Messages.Count); }
public void Heartbeat_WithOutput_SetsOutputOnHeartbeat() { var text = "text"; var client = new MockSensuClient(); var sut = new SensuMonitor(client, "testApp"); sut.Heartbeat(message: text); var message = client.Messages.First() as Heartbeat; Assert.Equal(text, message.Output); }
public void EnrichMessage_OnIHaveMeta_AddsMeta() { ISensuEnricher enricher = new HostInfoEnricher(); var sut = new MockSensuClient(); sut.EnrichWith(enricher); var message = new Ok("app_name", "some_metric"); sut.Send(message); Assert.True(message.Meta.ContainsKey("host_name")); }