public void LogFailure2LogToFlatFileTest()
        {
            string   _filePath = $"{nameof(LogFailure2LogToFlatFileTest)}.log";
            FileInfo _logFile  = new FileInfo(_filePath);

            if (_logFile.Exists)
            {
                _logFile.Delete();
            }
            MessageHandlerFactory   _factory          = new MessageHandlerFactory();
            ObservableEventListener _listener         = new ObservableEventListener();
            UDPMessageHandlerSemanticEventSource _log = UDPMessageHandlerSemanticEventSource.Log;

            _listener.EnableEvents(_log, EventLevel.LogAlways, Keywords.All);
            SinkSubscription <FlatFileSink> _FlatFileSink = _listener.LogToFlatFile(_filePath);

            _logFile.Refresh();
            Assert.IsTrue(_logFile.Exists);
            Assert.AreEqual <long>(0, _logFile.Length);

            _log.Failure(nameof(UDPMessageHandlerSemanticEventSourceUnitTest), nameof(LogFailure2LogToFlatFileTest), "LogFailure");

            _FlatFileSink.Sink.FlushAsync();
            _logFile.Refresh();
            Assert.IsTrue(_logFile.Length > 100);
            _FlatFileSink.Dispose();
        }
示例#2
0
 public void Dispose()
 {
     if (_subscription != null)
     {
         _subscription.Dispose();
     }
     GC.SuppressFinalize(this);
 }
示例#3
0
        public void FlatFileSinkTest()
        {
            string   _filePath = $"{nameof(FlatFileSinkTest)}.log";
            FileInfo _logFile  = new FileInfo(_filePath);

            if (_logFile.Exists)
            {
                _logFile.Delete();
            }
            SinkSubscription <FlatFileSink> m_FileSubscription = SinkExtensions.CreateSink(SemanticEventSource.Log, _filePath);

            _logFile.Refresh();
            Assert.IsTrue(_logFile.Exists);
            Assert.AreEqual <long>(0, _logFile.Length);
            SemanticEventUser _logUser = new SemanticEventUser();

            _logUser.DataProcessing();
            m_FileSubscription.Sink.FlushAsync();
            _logFile.Refresh();
            Assert.IsTrue(_logFile.Length > 100);
            m_FileSubscription.Dispose();
        }