Example #1
0
        public void CreateSimpleSensorWithInformationSource_NormalData_CountsInformationItemsCorrectly()
        {
            //arrange
            var informationSource = new SimpleInformationSource();
            var netEvenTArgs      = new NetworkEventArgs(string.Empty, 0, string.Empty, 0, string.Empty, DateTime.Now, Guid.NewGuid());

            informationSource.AddNetworkMessage(netEvenTArgs);
            informationSource.AddNetworkMessage(netEvenTArgs);
            informationSource.AddNetworkMessage(netEvenTArgs);
            var sensor = new Sensor(informationSource, null);

            //act

            //assert
            Assert.AreEqual(3, sensor.UnreadBufferCount);
        }
Example #2
0
        public void CreateSimpleSensorWithInformationSource_NormalData_ProcessMessageCorrectly()
        {
            //arrange
            var informationSource = new SimpleInformationSource();
            var netEvenTArgs      = new NetworkEventArgs(string.Empty, 0, string.Empty, 0, "hacking attempt", DateTime.Now, Guid.NewGuid());
            var netEvenTArgs2     = new NetworkEventArgs(string.Empty, 0, string.Empty, 0, "hello", DateTime.Now, Guid.NewGuid());
            var netEvenTArgs3     = new NetworkEventArgs(string.Empty, 0, string.Empty, 0, "hello", DateTime.Now, Guid.NewGuid());

            informationSource.AddNetworkMessage(netEvenTArgs);
            informationSource.AddNetworkMessage(netEvenTArgs2);
            informationSource.AddNetworkMessage(netEvenTArgs3);
            SimpleRule rule   = new SimpleRule("hacking attempt");
            var        sensor = new Sensor(informationSource, rule);

            //act
            bool result = sensor.ProcessNextMessage();

            //assert
            Assert.AreEqual(true, result);
            Assert.AreEqual(2, sensor.UnreadBufferCount);
        }