public void AsyncProxy_LogEntriesAreWrittenToSinks()
        {
            LogConfiguration configuration = new LogConfiguration();
            AsyncProxy asyncProxy = new AsyncProxy();
            ManualResetEvent stoppedEvent = new ManualResetEvent(false);
            TestSink sink = new TestSink(stoppedEvent);
            asyncProxy.Sinks.Add(sink);
            configuration.Sinks.Add(asyncProxy);
            using (LogKernel kernel = new LogKernel(configuration))
            {
                ILogger logger = kernel.GetLogger();
                logger.Write(LogLevel.Information, "A message");

                // Wait for the entry to be written.
                if (!stoppedEvent.WaitOne(TimeSpan.FromSeconds(3)))
                {
                    throw new TimeoutException("Timed out while waiting for entries to be written to sink.");
                }

                // Assert that the entry was written to the sink.
                Assert.IsNotNull(sink.Entry);
                Assert.AreEqual("A message", sink.Entry.Message);
                Assert.AreEqual(1, sink.WrittenEntries);
            }
        }
示例#2
0
        public async Task AsyncProxy_CallAsyncMethod()
        {
            var proxyObj = new AsyncProxy();
            var proxy    = proxyObj.GetProxyObject();

            var result = await proxy.GetTokenAsync();

            Assert.IsNotNull(result);
            Assert.AreEqual("TokenAsync", result);
        }