Ejemplo n.º 1
0
        public void ErrorsSinceTime_FiltersDate()
        {
            // ARRANGE
            var logEntries = new List <LogEntry>();

            logEntries.Add(new LogEntry {
                HostName = "Test", Message = "Test Log Entry 1", LogTime = new DateTime(2015, 2, 1), LogType = Convert.ToInt32(LogType.Error)
            });
            logEntries.Add(new LogEntry {
                HostName = "Test", Message = "Test Log Entry 2", LogTime = new DateTime(2016, 2, 1), LogType = Convert.ToInt32(LogType.Error)
            });
            logEntries.Add(new LogEntry {
                HostName = "Test", Message = "Test Log Entry 3", LogTime = new DateTime(2017, 2, 1), LogType = Convert.ToInt32(LogType.Error)
            });
            logEntries.Add(new LogEntry {
                HostName = "Test", Message = "Test Log Entry 4", LogTime = new DateTime(2017, 2, 1), LogType = Convert.ToInt32(LogType.Error)
            });
            logEntries.Add(new LogEntry {
                HostName = "Test", Message = "Test Log Entry 5", LogTime = new DateTime(2017, 2, 1), LogType = Convert.ToInt32(LogType.Error)
            });

            _mockContext.LogEntries.AddRange(logEntries);
            _mockContext.SaveChanges();

            // ACT
            var actualErrorCount = _readService.ErrorsSinceTime(new DateTime(2017, 2, 1));

            // ASSERT
            Assert.AreEqual(3, actualErrorCount);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read the number of Errors logged since a specified time
        /// </summary>
        /// <param name="startTime">When the first error log should have occured.</param>
        /// <returns></returns>
        public int ErrorsSinceTime(DateTime startTime)
        {
            var results = _readService.ErrorsSinceTime(startTime);

            return(results);
        }