Exemplo n.º 1
0
        public BaseUnitTest(ITestOutputHelper output)
        {
            var providor = new MXLoggerProvider(output.WriteLine, LogLevel.Trace);

            LoggerFactory = new LoggerFactory(new[] { providor });
            Logger        = LoggerFactory.CreateLogger("UnitTest");
        }
Exemplo n.º 2
0
        public LogEntryTest(ITestOutputHelper output)
        {
            WriteLine      = output.WriteLine;
            LoggerProvider = new MXLoggerProvider(WriteLine);
            var loggerFactory = new LoggerFactory(new[] { LoggerProvider });

            Logger = loggerFactory.CreateLogger("category");
        }
Exemplo n.º 3
0
        protected TestBase(ITestOutputHelper output)
        {
            Write = output.WriteLine;
            var provider = new MXLoggerProvider(output.WriteLine);

            LoggerFactory = new LoggerFactory(new[] { provider });

            Logger             = LoggerFactory.CreateLogger <TestBase>();
            SocketServerLogger = LoggerFactory.CreateLogger <RxSocketServer>();
            SocketClientLogger = LoggerFactory.CreateLogger <RxSocketClient>();
        }
Exemplo n.º 4
0
        public void LoggingLevelTest()
        {
            var loggerProvider = new MXLoggerProvider(WriteLine, LogLevel.Warning);
            var loggerFactory  = new LoggerFactory(new[] { loggerProvider });
            var logger         = loggerFactory.CreateLogger("category");

            logger.LogTrace("trace message");
            logger.LogDebug("debug message");
            logger.LogInformation("information message");
            logger.LogWarning("warning message");
            logger.LogError("error message");
            logger.LogCritical("critical message");
            Assert.Equal(3, loggerProvider.GetLogEntries().Count);
        }
Exemplo n.º 5
0
        protected BaseSystemTest(SystemTestFixture fixture, ITestOutputHelper output)
        {
            if (fixture.Client == null)
            {
                throw new NullReferenceException(nameof(fixture.Client));
            }

            var provider = new MXLoggerProvider(output.WriteLine);

            LoggerFactory = new LoggerFactory(new[] { provider });
            Logger        = LoggerFactory.CreateLogger("SystemTest");

            Client = fixture.Client;
            Id     = Client.Request.NextId();
            Logger.LogDebug($"BaseSystemTest: Id = {Id}.");
            subscription = Client.Response.Spy(Logger).Subscribe(Responses.Add);
        }
Exemplo n.º 6
0
        protected TestBase(ITestOutputHelper output)
        {
            Write          = output.WriteLine;
            LoggerProvider = new MXLoggerProvider(output.WriteLine);
            LoggerFactory  = new LoggerFactory(new[] { LoggerProvider });

            Logger             = LoggerFactory.CreateLogger <TestBase>();
            SocketServerLogger = LoggerFactory.CreateLogger <RxSocketServer>();
            SocketClientLogger = LoggerFactory.CreateLogger <RxSocketClient>();

            /*
             * AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs args) =>
             * {
             *  Debug.Write("CurrentDomain_UnhandledException");
             *  Write("CurrentDomain_UnhandledException");
             *  if (args.ExceptionObject is Exception exception)
             *      Write(exception.ToString());
             * };
             */
        }
Exemplo n.º 7
0
        public void Test()
        {
            var provider = new MXLoggerProvider(WriteLine);

            var serviceProvider = new ServiceCollection()
                                  .AddLogging(builder => builder.AddProvider(provider))
                                  .AddTransient <Component1>()
                                  .AddTransient <Component2>()
                                  .BuildServiceProvider();

            // inject ILogger<T>
            Component1 component1 = serviceProvider.GetService <Component1>() !;

            component1.Log("test");
            Assert.Equal("Info\t  MXLogger.xUnitTests.Component1\t  test\t  ", provider.Format(provider.GetLogEntries().Last()));

            // inject ILoggerFactory
            Component2 component2 = serviceProvider.GetService <Component2>() !;

            component2.Log("test");
            Assert.Equal("Info\t  Component2Name\t  test\t  ", provider.Format(provider.GetLogEntries().Last()));
        }
Exemplo n.º 8
0
 public LogFormatTest(ITestOutputHelper output)
 {
     Write          = output.WriteLine;
     LoggerProvider = new MXLoggerProvider(Write);
 }