<commit_before>using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Example.Instrumented.Library;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;

namespace Pocket.Tests
{
    public class LoggerDiscoveryTests
    {
        private readonly ITestOutputHelper output;

        public LoggerDiscoveryTests(ITestOutputHelper output)
        {
            this.output = output;
        }

        [Fact]
        public async Task Loggers_in_referenced_assemblies_can_be_discovered_and_subscribed()
        {
            var log = new List<IReadOnlyCollection<KeyValuePair<string, object>>>();

            var message = $"hello from {nameof(Loggers_in_referenced_assemblies_can_be_discovered_and_subscribed)}";

            using (Log.DiscoverAndSubscribe(log.Add))
            {
                await Task.Delay(100);
                Class1.EmitSomeLogEvents(message);
            }

            foreach (var e in log)
            {
                output.WriteLine(e.ToString());
            }

            log.Should().Contain(e => e.ToString().Contains(message));
        }

        [Fact]
        public async Task Loggers_in_referenced_assemblies_can_be_unsubscribed()
        {
            var log = new List<IReadOnlyCollection<KeyValuePair<string, object>>>();

            using (Log.DiscoverAndSubscribe(log.Add))
            {
                await Task.Delay(100);
                Class1.EmitSomeLogEvents($"before unsubscribe");
            }
<commit_msg>experiment #2 to see why discovery tests are flaky<commit_after>using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Example.Instrumented.Library;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;

namespace Pocket.Tests
{
    public class LoggerDiscoveryTests
    {
        private readonly ITestOutputHelper output;

        public LoggerDiscoveryTests(ITestOutputHelper output)
        {
            this.output = output;
        }

        [Fact]
        public async Task Loggers_in_referenced_assemblies_can_be_discovered_and_subscribed()
        {
            var log = new List<IReadOnlyCollection<KeyValuePair<string, object>>>();

            var message = $"hello from {nameof(Loggers_in_referenced_assemblies_can_be_discovered_and_subscribed)}";

            using (Log.DiscoverAndSubscribe(log.Add))
            {
                Class1.EmitSomeLogEvents(message);
                await Task.Delay(100);
            }

            foreach (var e in log)
            {
                output.WriteLine(e.ToString());
            }

            log.Should().Contain(e => e.ToString().Contains(message));
        }

        [Fact]
        public async Task Loggers_in_referenced_assemblies_can_be_unsubscribed()
        {
            var log = new List<IReadOnlyCollection<KeyValuePair<string, object>>>();

            using (Log.DiscoverAndSubscribe(log.Add))
            {
                Class1.EmitSomeLogEvents($"before unsubscribe");
                await Task.Delay(100);
            }

{'fraction_non_alphanumeric': 0.08597580908793724, 'fraction_numerical': 0.005557371690094802, 'mean_word_length': 2.2518597236981934, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3389441', 'n_tokens_mistral': 852, 'n_tokens_neox': 827, 'n_words': 152}