Simulates sending Syslogs over the network.
예제 #1
0
        private void RunCompareSendReceive(TimeSpan duration, TimeSpan delay)
        {
            ReceiveTxSyslog txReceiver = new ReceiveTxSyslog(new IPEndPoint(IPAddress.Parse(TxSyslogTestSettings.TargetIP), TxSyslogTestSettings.TargetPort), 10);

            txReceiver.RunCount();
            var txRecdObs = txReceiver.ObserveTx();

            var receivedList = new List <Syslog>();

            txRecdObs
            .Subscribe <Syslog>(j => receivedList.Add(j));

            TxSyslogSender sysSend  = new TxSyslogSender();
            var            sendTask = sysSend.StartSendAsync(TxSyslogTestSettings.SourceIP,
                                                             TxSyslogTestSettings.TargetIP,
                                                             TxSyslogTestSettings.TargetPort,
                                                             delay,
                                                             duration,
                                                             TxSyslogTestSettings.MessageList);

            var counter = sendTask.Result;

            Assert.AreEqual(counter, txReceiver.Counter);

            for (int c = 0; c < txReceiver.Counter; c++)
            {
                Assert.AreEqual(sysSend.SentList[c].Fac, receivedList[c].LogFacility);
                Assert.AreEqual(sysSend.SentList[c].Sev, receivedList[c].LogSeverity);
                Assert.AreEqual(TxSyslogTestSettings.SourceIP, receivedList[c].SourceIpAddress);
                Assert.AreEqual(sysSend.SentList[c].Message.ToLowerInvariant(), receivedList[c].Message.ToLowerInvariant());
                Console.Out.WriteLine(receivedList[c].Message);
                Console.Out.WriteLine(sysSend.SentList[c].Message);
            }
        }
예제 #2
0
        private void RunCompareSendReceive(TimeSpan duration, TimeSpan delay)
        {
            ReceiveTxSyslog txReceiver = new ReceiveTxSyslog(new IPEndPoint(IPAddress.Parse(TxSyslogTestSettings.TargetIP), TxSyslogTestSettings.TargetPort), 10);
            txReceiver.RunCount();
            var txRecdObs = txReceiver.ObserveTx();

            var receivedList = new List<Syslog>();
            txRecdObs
                .Subscribe<Syslog>(j => receivedList.Add(j));

            TxSyslogSender sysSend = new TxSyslogSender();
            var sendTask = sysSend.StartSendAsync(TxSyslogTestSettings.SourceIP,
                TxSyslogTestSettings.TargetIP,
                TxSyslogTestSettings.TargetPort,
                delay,
                duration,
                TxSyslogTestSettings.MessageList);

            var counter = sendTask.Result;

            Assert.AreEqual(counter, txReceiver.Counter);

            for (int c = 0; c < txReceiver.Counter; c++)
            {
                Assert.AreEqual(sysSend.SentList[c].Fac, receivedList[c].LogFacility);
                Assert.AreEqual(sysSend.SentList[c].Sev, receivedList[c].LogSeverity);
                Assert.AreEqual(TxSyslogTestSettings.SourceIP, receivedList[c].SourceIpAddress);
                Assert.AreEqual(sysSend.SentList[c].Message.ToLowerInvariant(), receivedList[c].Message.ToLowerInvariant());
                Console.Out.WriteLine(receivedList[c].Message);
                Console.Out.WriteLine(sysSend.SentList[c].Message);
            }
        }