コード例 #1
0
        public void Writes_Blank_Line_To_File()
        {
            using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist()))
            {
                logger.WriteLine();
            }

            Assert.That(
                File.ReadAllLines(FileMocks.FileThatDoesNotExist()).Length,
                Is.EqualTo(2)
                );
        }
コード例 #2
0
        public void Writes_Simple_Message_To_File()
        {
            string message = "This is a log message";

            using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist()))
            {
                logger.WriteLine(message);
            }

            Assert.That(
                File.ReadAllText(FileMocks.FileThatDoesNotExist()),
                Is.StringContaining(message)
                );
        }
コード例 #3
0
        public void Writes_Format_Message_To_File()
        {
            string format = "This is a log format with 2 params {0} {1}";
            string param1 = "param1";
            string param2 = "param2";

            using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist()))
            {
                logger.WriteLine(format, param1, param2);
            }

            Assert.That(
                File.ReadAllText(FileMocks.FileThatDoesNotExist()),
                Is.StringContaining(param1).And.StringContaining(param2)
                );
        }
コード例 #4
0
    private static async Task Main(string[] args)
    {
        List <Account> accounts = new List <Account>();
        ISimpleLogger  logger;

#if DEBUG
        logger = new SimpleConsoleLogger();
#else
        logger = new SimpleFileLogger(AppContext.BaseDirectory);
#endif

        try
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(AppContext.BaseDirectory)
                          .AddJsonFile("appsettings.json");

            IConfigurationRoot configuration = builder.Build();
            configuration.GetSection("accounts").Bind(accounts);

            using (var service = new VkCelebrationSchedulerService(accounts, logger))
            {
#if DEBUG
                await service.RunAsConsole(args);
#else
                ServiceBase.Run(service);
#endif
            }
        }
        catch (Exception ex)
        {
            logger.WriteException(ex);
            logger.WriteLine("=====================================================");
        }
        finally
        {
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }
コード例 #5
0
ファイル: FileLoggingTests.cs プロジェクト: fr33k3r/SODA.NET
        public void Writes_Format_Message_To_File()
        {
            string format = "This is a log format with 2 params {0} {1}";
            string param1 = "param1";
            string param2 = "param2";

            using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist()))
            {
                logger.WriteLine(format, param1, param2);
            }

            Assert.That(
                File.ReadAllText(FileMocks.FileThatDoesNotExist()),
                Is.StringContaining(param1).And.StringContaining(param2)
            );
        }
コード例 #6
0
ファイル: FileLoggingTests.cs プロジェクト: fr33k3r/SODA.NET
        public void Writes_Simple_Message_To_File()
        {
            string message = "This is a log message";

            using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist()))
            {
                logger.WriteLine(message);
            }

            Assert.That(
                File.ReadAllText(FileMocks.FileThatDoesNotExist()),
                Is.StringContaining(message)
            );
        }
コード例 #7
0
ファイル: FileLoggingTests.cs プロジェクト: fr33k3r/SODA.NET
        public void Writes_Blank_Line_To_File()
        {
            using (var logger = new SimpleFileLogger(FileMocks.FileThatDoesNotExist()))
            {
                logger.WriteLine();
            }

            Assert.That(
                File.ReadAllLines(FileMocks.FileThatDoesNotExist()).Length,
                Is.EqualTo(2)
            );
        }