Пример #1
0
        public void CreateConsoleLogger_ShouldInstanceOfILogger()
        {
            var factory = new ConsoleLoggerFactory();

            var instance = factory.GetLogger("dummy");

            Assert.IsInstanceOfType(instance, typeof(ILogger));

            instance.Debug(null);
            instance.Information(null);
            instance.Warning(null);
            instance.Error(null);
        }
        public async Task NoProblem()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(colored: false);
            var factory = new TplAsyncTaskFactory(consoleLoggerFactory);
            var logger  = consoleLoggerFactory.GetLogger <VerifyAssumptionAboutDisposingAsyncTaskMultipleTimes>();
            var task    = factory.Create("test-task", intervalSeconds: 1, action: async() => logger.Info("Called back"));

            task.Start();

            await Task.Delay(TimeSpan.FromSeconds(4));

            task.Dispose();
            task.Dispose();
            task.Dispose();
            task.Dispose();
        }