public void ReportHealthyShouldWriteMessage()
        {
            // Setup
            var configuration = BuildTestConfigration();

            // Exercise
            using (CustomHealthReporter target = new CustomHealthReporter(configuration))
            {
                target.Activate();
                target.ReportHealthy("Healthy message.", "UnitTest");
                // Verify
                Assert.True(target.WriteOperation.WaitOne(StreamOperationTimeoutMsec));
                target.StreamWriterMock.Verify(
                    s => s.WriteLine(
                        It.Is <string>(msg => msg.Contains("UnitTest,Message,Healthy message."))),
                    Times.Exactly(1));
            }
        }
        public async void ReportHealthyShouldWriteMessage()
        {
            // Setup
            var configuration = BuildTestConfigration();

            // Exercise
            using (CustomHealthReporter target = new CustomHealthReporter(configuration))
            {
                target.Activate();
                target.ReportHealthy("Healthy message.", "UnitTest");
                // Verify
                await Task.Delay(DefaultDelayMsec);

                target.StreamWriterMock.Verify(
                    s => s.WriteLine(
                        It.Is <string>(msg => msg.Contains("UnitTest,Message,Healthy message."))),
                    Times.Exactly(1));
            }
        }
        public async void ReporterShouldFilterOutMessage()
        {
            // Setup
            var configuration = BuildTestConfigration();

            configuration[MinReportLevelKey] = "Warning";

            // Exercise
            using (CustomHealthReporter target = new CustomHealthReporter(configuration))
            {
                target.Activate();
                target.ReportHealthy("Supposed to be filtered.", "UnitTest");
                // Verify that message is filtered out.
                await Task.Delay(DefaultDelayMsec);

                target.StreamWriterMock.Verify(
                    s => s.WriteLine(
                        It.IsAny <string>()),
                    Times.Exactly(0));

                // Verify that warning is not filtered out.
                target.ReportWarning("Warning message", "UnitTests");
                await Task.Delay(DefaultDelayMsec);

                target.StreamWriterMock.Verify(
                    s => s.WriteLine(
                        It.IsAny <string>()),
                    Times.Exactly(1));

                // Verify that error is not filtered out.
                target.ReportWarning("Error message", "UnitTests");
                await Task.Delay(DefaultDelayMsec);

                target.StreamWriterMock.Verify(
                    s => s.WriteLine(
                        It.IsAny <string>()),
                    Times.Exactly(2));
            }
        }