public void LoggingStateReader_Errors()
        {
            var sb = new StringBuilder();

            using (var sw = new StringWriter(sb))
            {
                using var r      = new MyReader { Throw = true };
                using var reader = new LoggingStateReader(r, sw);

                Assert.ThrowsException <NotImplementedException>(() => _ = reader.GetCategories());
                Assert.ThrowsException <NotImplementedException>(() => _ = reader.TryGetItemKeys("foo", out _));
                Assert.ThrowsException <NotImplementedException>(() => _ = reader.TryGetItemReader("foo", "bar", out _));
                Assert.ThrowsException <NotImplementedException>(() => reader.Dispose());

                r.Throw = false;
            }

            var log = sb.ToString();

            foreach (var entry in new[]
            {
                "GetCategories()/Start",
                "GetCategories()/Error",
                "GetCategories()/Stop",

                "TryGetItemKeys(foo)/Start",
                "TryGetItemKeys(foo)/Error",
                "TryGetItemKeys(foo)/Stop",

                "TryGetItemReader(foo, bar)/Start",
                "TryGetItemReader(foo, bar)/Error",
                "TryGetItemReader(foo, bar)/Stop",

                "Dispose()/Start",
                "Dispose()/Error",
                "Dispose()/Stop",
            })
            {
                Assert.IsTrue(log.Contains(entry), "Not found: '" + entry + "'");
            }
        }
        public void LoggingStateReader_Basics()
        {
            var sb = new StringBuilder();

            using (var sw = new StringWriter(sb))
            {
                using var r      = new MyReader();
                using var reader = new LoggingStateReader(r, sw);

                var cat = reader.GetCategories();
                CollectionAssert.AreEqual(new[] { "A" }, cat.ToList());

                var f1 = reader.TryGetItemKeys("foo", out var keys);
                Assert.IsTrue(f1);
                CollectionAssert.AreEqual(new[] { "B" }, keys.ToList());

                var f2 = reader.TryGetItemReader("foo", "bar", out var s);
                Assert.IsTrue(f2);
                Assert.IsNotNull(s);
            }

            var log = sb.ToString();

            foreach (var entry in new[]
            {
                "GetCategories()/Start",
                "GetCategories()/Stop",

                "TryGetItemKeys(foo)/Start",
                "TryGetItemKeys(foo)/Stop",

                "TryGetItemReader(foo, bar)/Start",
                "TryGetItemReader(foo, bar)/Stop",

                "Dispose()/Start",
                "Dispose()/Stop",
            })
            {
                Assert.IsTrue(log.Contains(entry), "Not found: '" + entry + "'");
            }
        }