Exemplo n.º 1
0
        public void TestJobLoggerClassDisplayOnlyErrors()
        {
            var mockup = new FileMockupLogger();

            var supportedloggers = new List<ILogger>();
            supportedloggers.Add(mockup);

            var supportedLogTypes = new List<LogMessageType>();
            supportedLogTypes.Add(LogMessageType.ERROR);

            JobLoggerVs2 jobLogger = new JobLoggerVs2(supportedloggers, supportedLogTypes);

            mockup.CurrentMessageType = null;
            jobLogger.OutputLog("Message for logging Error", LogMessageType.ERROR);
            Assert.IsTrue(mockup.CurrentMessageType == LogMessageType.ERROR);

            mockup.CurrentMessageType = null;
            jobLogger.OutputLog("Message for logging Warning", LogMessageType.WARNING);
            Assert.IsTrue(mockup.CurrentMessageType == null);

            mockup.CurrentMessageType = null;
            jobLogger.OutputLog("Message for logging Message", LogMessageType.MESSAGE);
            Assert.IsTrue(mockup.CurrentMessageType == null);
        }
Exemplo n.º 2
0
        public void TestMultipleLoggers()
        {
            var fileMockup = new FileMockupLogger();
            var dbMockup = new DataBaseMockupLogger();
            var consoleMockup = new ConsoleMockupLogger();

            var supportedloggers = new List<ILogger>();
            supportedloggers.Add(fileMockup);
            supportedloggers.Add(dbMockup);
            supportedloggers.Add(consoleMockup);

            var supportedLogTypes = new List<LogMessageType>();
            supportedLogTypes.Add(LogMessageType.ERROR);

            JobLoggerVs2 jobLogger = new JobLoggerVs2(supportedloggers, supportedLogTypes);

            jobLogger.OutputLog("ExecuteLogger", LogMessageType.WARNING);
            Assert.IsTrue(string.IsNullOrEmpty(fileMockup.CurrentMessage));
            Assert.IsTrue(string.IsNullOrEmpty(dbMockup.CurrentMessage));
            Assert.IsTrue(string.IsNullOrEmpty(consoleMockup.CurrentMessage));

            jobLogger.OutputLog("ExecuteLogger", LogMessageType.ERROR);
            Assert.IsTrue(fileMockup.CurrentMessage.Equals("ExecuteLogger"));
            Assert.IsTrue(dbMockup.CurrentMessage.Equals("ExecuteLogger"));
            Assert.IsTrue(consoleMockup.CurrentMessage.Equals("ExecuteLogger"));
        }