Beispiel #1
0
        public void CompressedReadWriteTests()
        {
            TestHelper.CleanupTestFolder();
            string          directoryPath = Path.Combine(TestHelper.TestFolder, "GzipCKMonWriterClientTest");
            ActivityMonitor m             = new ActivityMonitor();
            var             client        = new CKMonWriterClient(directoryPath, 20000, LogFilter.Undefined, true);

            m.Output.RegisterClient(client);
            using (m.OpenWarn().Send("Group test"))
            {
                m.Info().Send("Line test");
            }
            // This closes the client: the file is then compressed asynchronously
            // on a thread from the ThreadPool.
            Assert.That(client.IsOpened);
            m.Output.UnregisterClient(client);
            string    ckmonPath = TestHelper.WaitForCkmonFilesInDirectory(directoryPath, 1)[0];
            LogReader r         = LogReader.Open(ckmonPath);

            r.MoveNext();
            Assert.That(r.Current.LogType, Is.EqualTo(LogEntryType.OpenGroup));
            Assert.That(r.Current.Text, Is.EqualTo("Group test"));
            r.MoveNext();
            Assert.That(r.Current.LogType, Is.EqualTo(LogEntryType.Line));
            Assert.That(r.Current.Text, Is.EqualTo("Line test"));
            r.MoveNext();
            Assert.That(r.Current.LogType, Is.EqualTo(LogEntryType.CloseGroup));
            bool hasRemainingEntries = r.MoveNext();

            Assert.That(hasRemainingEntries, Is.False);
        }
Beispiel #2
0
 public void CompressedReadWriteTests()
 {
     TestHelper.CleanupTestFolder();
     string directoryPath = Path.Combine( TestHelper.TestFolder, "GzipCKMonWriterClientTest" );
     ActivityMonitor m = new ActivityMonitor();
     var client = new CKMonWriterClient( directoryPath, 20000, LogFilter.Undefined, true );
     m.Output.RegisterClient( client );
     using( m.OpenWarn().Send( "Group test" ) )
     {
         m.Info().Send( "Line test" );
     }
     // This closes the client: the file is then compressed asynchronously
     // on a thread from the ThreadPool.
     Assert.That( client.IsOpened );
     m.Output.UnregisterClient( client );
     string ckmonPath = TestHelper.WaitForCkmonFilesInDirectory( directoryPath, 1 )[0];
     LogReader r = LogReader.Open( ckmonPath );
     r.MoveNext();
     Assert.That( r.Current.LogType, Is.EqualTo( LogEntryType.OpenGroup ) );
     Assert.That( r.Current.Text, Is.EqualTo( "Group test" ) );
     r.MoveNext();
     Assert.That( r.Current.LogType, Is.EqualTo( LogEntryType.Line ) );
     Assert.That( r.Current.Text, Is.EqualTo( "Line test" ) );
     r.MoveNext();
     Assert.That( r.Current.LogType, Is.EqualTo( LogEntryType.CloseGroup ) );
     bool hasRemainingEntries = r.MoveNext();
     Assert.That( hasRemainingEntries, Is.False );
 }