Пример #1
0
        public void DistributedLoggerBadPath()
        {
            DistributedFileLogger fileLogger = new DistributedFileLogger();
            fileLogger.NodeId = 0;
            fileLogger.Initialize(new EventSource());

            fileLogger.NodeId = 1;
            fileLogger.Parameters = "logfile=" + Path.Combine(Environment.CurrentDirectory, "\\DONTEXIST\\mylogfile.log");
            fileLogger.Initialize(new EventSource());
            Assert.IsTrue(string.Compare(fileLogger.InternalFilelogger.Parameters, ";ShowCommandLine;logfile=" + Path.Combine(Environment.CurrentDirectory, "\\DONTEXIST\\mylogfile2.log"), StringComparison.OrdinalIgnoreCase) == 0);
        }
Пример #2
0
        public void DistributedLoggerNullEmpty()
        {
            DistributedFileLogger fileLogger = new DistributedFileLogger();
            fileLogger.NodeId = 0;
            fileLogger.Initialize(new EventSource());

            fileLogger.NodeId = 1;
            fileLogger.Parameters = "logfile=";
            fileLogger.Initialize(new EventSource());
            Assert.Fail();
        }
Пример #3
0
        public void DistributedFileLoggerParameters()
        {
                DistributedFileLogger fileLogger = new DistributedFileLogger();
                try
                {
                    fileLogger.NodeId = 0;
                    fileLogger.Initialize(new EventSource());
                    Assert.IsTrue(string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=msbuild0.log;", StringComparison.OrdinalIgnoreCase) == 0);
                    fileLogger.Shutdown();

                    fileLogger.NodeId = 3;
                    fileLogger.Parameters = "logfile="+Path.Combine(Environment.CurrentDirectory,"mylogfile.log");
                    fileLogger.Initialize(new EventSource());
                    Assert.IsTrue(string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=" + Path.Combine(Environment.CurrentDirectory, "mylogfile3.log") + ";", StringComparison.OrdinalIgnoreCase) == 0);
                    fileLogger.Shutdown();

                    fileLogger.NodeId = 4;
                    fileLogger.Parameters = "logfile=" + Path.Combine(Environment.CurrentDirectory, "mylogfile.log");
                    fileLogger.Initialize(new EventSource());
                    Assert.IsTrue(string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=" + Path.Combine(Environment.CurrentDirectory, "mylogfile4.log") + ";", StringComparison.OrdinalIgnoreCase) == 0);
                    fileLogger.Shutdown();

                    Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "tempura"));
                    fileLogger.NodeId = 1;
                    fileLogger.Parameters = "logfile=" + Path.Combine(Environment.CurrentDirectory, "tempura\\mylogfile.log");
                    fileLogger.Initialize(new EventSource());
                    Assert.IsTrue(string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=" + Path.Combine(Environment.CurrentDirectory, "tempura\\mylogfile1.log") + ";", StringComparison.OrdinalIgnoreCase) == 0);
                    fileLogger.Shutdown();
                }
                finally
                {
                    if(Directory.Exists(Path.Combine(Environment.CurrentDirectory, "tempura")))
                    {
                        File.Delete(Path.Combine(Environment.CurrentDirectory, "tempura\\mylogfile1.log"));
                        Directory.Delete(Path.Combine(Environment.CurrentDirectory, "tempura"));
                    }
                    File.Delete(Path.Combine(Environment.CurrentDirectory, "mylogfile0.log"));
                    File.Delete(Path.Combine(Environment.CurrentDirectory, "mylogfile3.log"));
                    File.Delete(Path.Combine(Environment.CurrentDirectory, "mylogfile4.log"));
                }
        }