Exemplo n.º 1
0
        public void TestRemoteLogging()
        {
            var loggingDb = manager.GetDatabase("cbl-logging");
            var logger    = new RemoteLogger(loggingDb, "remotelogging-test");

            Log.AddLogger(logger);
            var r = new Random();

            for (int i = 0; i < 15; i++)
            {
                var secs = r.NextDouble();
                Log.To.Database.W("RemoteLoggingTest", "A test warning message, waiting {0} sec", secs);
                Log.To.Database.I("RemoteLoggingTest", "A test info message, waiting {0} sec", secs);
                Log.To.Database.E("RemoteLoggingTest", "A test error message, waiting {0} sec", secs);
                Thread.Sleep(TimeSpan.FromSeconds(secs));
            }

            logger.Flush();
            logger.Dispose();

            Thread.Sleep(3000);

            Assert.AreEqual(1, loggingDb.GetDocumentCount());
            var doc    = loggingDb.CreateAllDocumentsQuery().Run().First();
            var events = doc.Document.GetProperty("events").AsList <object>();

            Assert.AreEqual(45, events.Count);
        }