コード例 #1
0
ファイル: FileLogger_Tests.cs プロジェクト: 3F/IeXod
        public void ValidVerbosities()
        {
            string[]          verbositySettings     = new string[] { "Q", "quiet", "m", "minimal", "N", "normal", "d", "detailed", "diag", "DIAGNOSTIC" };
            LoggerVerbosity[] verbosityEnumerations = new LoggerVerbosity[] { LoggerVerbosity.Quiet, LoggerVerbosity.Quiet,
                                                                              LoggerVerbosity.Minimal, LoggerVerbosity.Minimal,
                                                                              LoggerVerbosity.Normal, LoggerVerbosity.Normal,
                                                                              LoggerVerbosity.Detailed, LoggerVerbosity.Detailed,
                                                                              LoggerVerbosity.Diagnostic, LoggerVerbosity.Diagnostic };
            for (int i = 0; i < verbositySettings.Length; i++)
            {
                FileLogger fl = new FileLogger();
                fl.Parameters = "verbosity=" + verbositySettings[i] + ";";
                EventSourceSink es = new EventSourceSink();
                fl.Initialize(es);
                fl.Shutdown();
                Assert.Equal(fl.Verbosity, verbosityEnumerations[i]);
            }

            // Do the same using the v shorthand
            for (int i = 0; i < verbositySettings.Length; i++)
            {
                FileLogger fl = new FileLogger();
                fl.Parameters = "v=" + verbositySettings[i] + ";";
                EventSourceSink es = new EventSourceSink();
                fl.Initialize(es);
                fl.Shutdown();
                Assert.Equal(fl.Verbosity, verbosityEnumerations[i]);
            }
        }
コード例 #2
0
ファイル: FileLogger_Tests.cs プロジェクト: 3F/IeXod
        public void SpecificVerbosity()
        {
            string log = null;

            try
            {
                log = GetTempFilename();
                FileLogger      fl = new FileLogger();
                EventSourceSink es = new EventSourceSink();
                fl.Parameters = "verbosity=diagnostic;logfile=" + log; // diagnostic specific setting
                fl.Verbosity  = LoggerVerbosity.Quiet;                 // quiet global setting
                fl.Initialize(es);
                fl.MessageHandler(null, new BuildMessageEventArgs("message here", null, null, MessageImportance.High));
                fl.Shutdown();

                // expect message to appear because diagnostic not quiet verbosity was used
                VerifyFileContent(log, "message here");
            }
            finally
            {
                if (null != log)
                {
                    File.Delete(log);
                }
            }
        }
コード例 #3
0
ファイル: FileLogger_Tests.cs プロジェクト: 3F/IeXod
        /// <summary>
        /// Creates a FileLogger, sets its parameters and initializes it,
        /// logs a message to it, and calls shutdown
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private void SetUpFileLoggerAndLogMessage(string parameters, BuildMessageEventArgs message)
        {
            FileLogger      fl = new FileLogger();
            EventSourceSink es = new EventSourceSink();

            fl.Parameters = parameters;
            fl.Initialize(es);
            fl.MessageHandler(null, message);
            fl.Shutdown();
            return;
        }
コード例 #4
0
ファイル: FileLogger_Tests.cs プロジェクト: 3F/IeXod
 public void InvalidVerbosity()
 {
     Assert.Throws <LoggerException>(() =>
     {
         FileLogger fl      = new FileLogger();
         fl.Parameters      = "verbosity=CookiesAndCream";
         EventSourceSink es = new EventSourceSink();
         fl.Initialize(es);
     }
                                     );
 }
コード例 #5
0
ファイル: FileLogger_Tests.cs プロジェクト: 3F/IeXod
        public void InvalidEncoding()
        {
            Assert.Throws <LoggerException>(() =>
            {
                string log = null;

                try
                {
                    log                = GetTempFilename();
                    FileLogger fl      = new FileLogger();
                    EventSourceSink es = new EventSourceSink();
                    fl.Parameters      = "encoding=foo;logfile=" + log;
                    fl.Initialize(es);
                }
                finally
                {
                    if (null != log)
                    {
                        File.Delete(log);
                    }
                }
            }
                                            );
        }