public async Task EventWriterReportsOnDispose()
        {
            var         progress    = new AwaitableProgress <EventWrittenProgressReport>();
            var         stdout      = new StringWriter();
            var         stderr      = new StringWriter();
            EventWriter eventWriter = new EventWriter(
                stdout: stdout,
                stderr: stderr,
                progress: progress
                );

            Task <EventWrittenProgressReport> t = progress.AwaitProgressAsync();

            #pragma warning disable 4014
            //// Because this call is not awaited, execution of the current
            //// method continues before the call is completed. Consider
            //// applying the 'await' operator to the result of the call.
            eventWriter.CompleteAsync();
            #pragma warning restore 4014

            EventWrittenProgressReport r = await t;

            Assert.Equal(new Event(), r.WrittenEvent);
            Assert.Equal("", stderr.ToString());
            Assert.Equal("", stdout.ToString());
        }
        public async Task EventWriterReportsOnWrite()
        {
            var         progress    = new AwaitableProgress <EventWrittenProgressReport>();
            var         stdout      = new StringWriter();
            var         stderr      = new StringWriter();
            EventWriter eventWriter = new EventWriter(
                stdout: stdout,
                stderr: stderr,
                progress: progress
                );

            try
            {
                var writtenTask = progress.AwaitProgressAsync();
                await eventWriter.QueueEventForWriting(new Event
                {
                    Time = DateTime.FromFileTime(0),
                    Data = "Boris the mad baboon"
                });

                var report = await writtenTask;

                Assert.Equal("Boris the mad baboon", report.WrittenEvent.Data);
                Assert.True(stdout.ToString().Trim().Contains("<data>Boris the mad baboon</data>"));
                Assert.True(stdout.ToString().Trim().Contains("<time>-11644502400</time>"));
                Assert.Equal("", stderr.ToString());

                var completedTask = progress.AwaitProgressAsync();
                await eventWriter.CompleteAsync();

                report = await completedTask;

                Assert.Equal("", stderr.ToString());
                Assert.True(stdout.ToString().Trim().EndsWith("</stream>"));
            }
            finally
            {
                // EventWriter.CompleteAsync() is idempotent, so there is no problem if this is invoked twice.
                eventWriter.CompleteAsync().Wait();
            }
        }