Example #1
0
        public void ProcessorTests_ParseEvents_FileEmpty()
        {
            // Arrange
            int          expected   = 0;
            Stream       fileStream = mAssembly.GetManifestResourceStream(_EMPTY_FILE);
            StreamReader reader     = new StreamReader(fileStream);

            // Act
            mCounter.ParseEvents(_TEST_DEVICE_ID, reader);
            int actual = mCounter.GetEventCount(_TEST_DEVICE_ID);

            // Assert
            Assert.AreEqual(expected, actual, "not equal");
        }
Example #2
0
        /// <summary>
        /// Logic to handle one file per thread.
        /// </summary>
        /// <param name="fileInfo"> Log file to process </param>
        private static void processLogFile(FileInfo fileInfo)
        {
            string          pattern = @"^device_(.+).txt";
            Regex           rgx     = new Regex(pattern, RegexOptions.IgnoreCase);
            MatchCollection matches = rgx.Matches(fileInfo.Name);

            if (matches.Count != 1 && matches[0].Groups.Count != 2)
            {
                return;
            }

            string       deviceId = matches[0].Groups[1].Value;
            StreamReader eventLog = new StreamReader(fileInfo.FullName);

            IEventCounter eventCounter = EventCounter.Instance;

            eventCounter.ParseEvents(deviceId, eventLog);
            int faultySeqCount = eventCounter.GetEventCount(deviceId);

            Console.WriteLine(string.Format("File : {0} | Device ID : {1} | Fault Event Count : {2}", fileInfo.Name, deviceId, faultySeqCount));
        }