Ejemplo n.º 1
0
        public void DistributedLoggerNullEmpty()
        {
            Assert.Throws<LoggerException>(() =>
            {
                DistributedFileLogger fileLogger = new DistributedFileLogger();
                fileLogger.NodeId = 0;
                fileLogger.Initialize(new EventSourceSink());

                fileLogger.NodeId = 1;
                fileLogger.Parameters = "logfile=";
                fileLogger.Initialize(new EventSourceSink());
                Assert.True(false);
            }
           );
        }
Ejemplo n.º 2
0
        public void DistributedLoggerBadPath()
        {
            Assert.Throws<LoggerException>(() =>
            {
                DistributedFileLogger fileLogger = new DistributedFileLogger();
                fileLogger.NodeId = 0;
                fileLogger.Initialize(new EventSourceSink());

                fileLogger.NodeId = 1;
                fileLogger.Parameters = "logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "\\DONTEXIST\\mylogfile.log");
                fileLogger.Initialize(new EventSourceSink());
                Assert.Equal(0, string.Compare(fileLogger.InternalFilelogger.Parameters, ";ShowCommandLine;logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "\\DONTEXIST\\mylogfile2.log"), StringComparison.OrdinalIgnoreCase));
            }
           );
        }
Ejemplo n.º 3
0
        public void DistributedLoggerNullEmpty()
        {
            DistributedFileLogger fileLogger = new DistributedFileLogger();
            fileLogger.NodeId = 0;
            fileLogger.Initialize(new EventSourceSink());

            fileLogger.NodeId = 1;
            fileLogger.Parameters = "logfile=";
            fileLogger.Initialize(new EventSourceSink());
            Assert.Fail();
        }
Ejemplo n.º 4
0
        public void DistributedFileLoggerParameters()
        {
            DistributedFileLogger fileLogger = new DistributedFileLogger();
            try
            {
                fileLogger.NodeId = 0;
                fileLogger.Initialize(new EventSourceSink());
                Assert.Equal(0, string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=msbuild0.log;", StringComparison.OrdinalIgnoreCase));
                fileLogger.Shutdown();

                fileLogger.NodeId = 3;
                fileLogger.Parameters = "logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "mylogfile.log");
                fileLogger.Initialize(new EventSourceSink());
                Assert.Equal(0, string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "mylogfile3.log") + ";", StringComparison.OrdinalIgnoreCase));
                fileLogger.Shutdown();

                fileLogger.NodeId = 4;
                fileLogger.Parameters = "logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "mylogfile.log");
                fileLogger.Initialize(new EventSourceSink());
                Assert.Equal(0, string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "mylogfile4.log") + ";", StringComparison.OrdinalIgnoreCase));
                fileLogger.Shutdown();

                Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "tempura"));
                fileLogger.NodeId = 1;
                fileLogger.Parameters = "logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "tempura\\mylogfile.log");
                fileLogger.Initialize(new EventSourceSink());
                Assert.Equal(0, string.Compare(fileLogger.InternalFilelogger.Parameters, "ForceNoAlign;ShowEventId;ShowCommandLine;logfile=" + Path.Combine(Directory.GetCurrentDirectory(), "tempura\\mylogfile1.log") + ";", StringComparison.OrdinalIgnoreCase));
                fileLogger.Shutdown();
            }
            finally
            {
                if (Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "tempura")))
                {
                    File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "tempura\\mylogfile1.log"));
                    Directory.Delete(Path.Combine(Directory.GetCurrentDirectory(), "tempura"));
                }
                File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "mylogfile0.log"));
                File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "mylogfile3.log"));
                File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "mylogfile4.log"));
            }
        }
Ejemplo n.º 5
0
        public void DistributedLoggerBadPath()
        {
            DistributedFileLogger fileLogger = new DistributedFileLogger();
            fileLogger.NodeId = 0;
            fileLogger.Initialize(new EventSourceSink());

            fileLogger.NodeId = 1;
            fileLogger.Parameters = "logfile=" + Path.Combine(Environment.CurrentDirectory, "\\DONTEXIST\\mylogfile.log");
            fileLogger.Initialize(new EventSourceSink());
            Assert.IsTrue(string.Compare(fileLogger.InternalFilelogger.Parameters, ";ShowCommandLine;logfile=" + Path.Combine(Environment.CurrentDirectory, "\\DONTEXIST\\mylogfile2.log"), StringComparison.OrdinalIgnoreCase) == 0);
        }