예제 #1
0
        public void Send_OneMessage_SyslogSenderCalled()
        {
            var message = new CefMessage(new DateTime(2016, 1, 1), "host", "Security", "threatmanager", "1.0", 100, "worm successfullystopped",
                                         CefSeverity.Emergency);

            _cefSender.Send(message, _serializer);

            _syslogSenderMock.Verify(x => x.Send(It.IsAny <SyslogMessage>(), It.IsAny <CefMessageSerializer>()), Times.Once);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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));
        }