Ejemplo n.º 1
0
        public void eventCounter_Returns0_whenFileDoesNotContainAnyFault()
        {
            // Arrange
            var eventCounter = new EventCounter();

            // Act
            eventCounter.ParseEvents("4", EventLog4);

            // Verify / Assert
            var eventCounts = JsonConvert.DeserializeObject <List <EventCount> >(eventCounter.GetEventCounts());

            Assert.AreEqual(eventCounts.First().eventCount, 0);
        }
Ejemplo n.º 2
0
        public void eventCounter_Returns2_whenFileContainsTwoFaults()
        {
            // Arrange
            var eventCounter = new EventCounter();

            // Act
            eventCounter.ParseEvents("3", EventLog3);

            // Verify / Assert
            var eventCounts = JsonConvert.DeserializeObject <List <EventCount> >(eventCounter.GetEventCounts());

            Assert.AreEqual(eventCounts.First().eventCount, 2);
        }
Ejemplo n.º 3
0
        public void eventCounter_Returns1_whenFileContainsSingleFaultWithRedundantStages()
        {
            // Arrange
            var eventCounter = new EventCounter();

            // Act
            eventCounter.ParseEvents("2", EventLog2);

            // Verify / Assert
            var eventCounts = JsonConvert.DeserializeObject <List <EventCount> >(eventCounter.GetEventCounts());

            Assert.AreEqual(eventCounts.First().eventCount, 1);
        }
Ejemplo n.º 4
0
        //
        // GET: /Index/
        public ActionResult Index()
        {
            string fileName1   = Server.MapPath(Url.Content("~/App_Data/myData.csv"));
            var    eventParser = new EventCounter();

            try
            {
                using (var eventLog1 = new StreamReader(fileName1))
                {
                    eventParser.ParseEvents("HV1", eventLog1);
                }
            }
            catch (IOException)
            {
                throw;
            }

            var model = new EventCountModel {
                EventCount = eventParser.EventCounts.First()
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public void ParseEvents_LogWithEmptyLines_EmptyLinesIgnored()
        {
            eventCtr.ParseEvents("Device 1", GenerateStreamReader(
                                     new string[]
            {
                getLogLine("2001-01-01 19:46:00", 0),
                string.Empty,
                string.Empty,
                getLogLine("2001-01-01 19:50:00", 1)
            }));

            Assert.AreEqual(0, eventCtr.GetEventCount("Device 1"));
        }
Ejemplo n.º 6
0
 public IActionResult Post(string id)
 {
     eventCounter.ParseEvents(id, null);
     return(Ok());
 }