public void CefSender_SendCef() { var serializer = new CefMessageSerializer(new SyslogRfc3164MessageSerializer()); using (var sender = new CefSender(new SyslogTcpSender("127.0.0.1", 514))) { var cef = new CefMessage(DateTimeOffset.UtcNow, "host", "Raiff", "ICDB", "1.1", 555, "test", CefSeverity.Error); Assert.That(() => sender.Send(cef, serializer), Throws.Nothing); } }
public void Send_TwoMessages_SyslogSenderCalledTwice() { var firstMessage = new CefMessage(new DateTime(2016, 1, 1), "host", "Security", "threatmanager", "1.0", 100, "worm successfullystopped", CefSeverity.Emergency); var secondMessage = new CefMessage(new DateTime(2016, 1, 1), "host", "Security", "threatmanager", "1.0", 100, "worm successfullystopped", CefSeverity.Emergency); var serializer = new CefMessageSerializer(new Mock <ISyslogMessageSerializer>().Object); var syslogSenderMock = new Mock <ISyslogMessageSender>(); var cefSender = new CefSender(syslogSenderMock.Object); cefSender.Send(new CefMessage[] { firstMessage, secondMessage }, serializer); syslogSenderMock.Verify(x => x.Send(It.IsAny <SyslogMessage>(), It.IsAny <CefMessageSerializer>()), Times.Exactly(2)); }
public CefSenderTests() { _syslogSenderMock = new Mock <ISyslogMessageSender>(); _cefSender = new CefSender(_syslogSenderMock.Object); _serializer = new CefMessageSerializer(new Mock <ISyslogMessageSerializer>().Object); }