Ejemplo n.º 1
0
        public void CatchTests()
        {
            IDefaultActivityLogger d = DefaultActivityLogger.Create();

            Assert.Throws <ArgumentNullException>(() => d.Catch(null));

            d.Error("Pouf");
            using (d.Catch(e => Assert.That(String.Join(",", e.Select(t => t.Text)) == "One,Two")))
            {
                d.Error("One");
                d.Warn("Warn");
                d.Fatal("Two");
            }
            d.Error("Out...");
            using (d.Catch(e => e.Single(t => t.Text == "Two"), LogLevelFilter.Fatal))
            {
                d.Error("One");
                d.Warn("Warn");
                d.Fatal("Two");
            }

            using (d.Catch(e => Assert.Fail("No Error occured.")))
            {
                d.Trace("One");
                d.Warn("Warn");
            }

            using (d.Catch(e => Assert.Fail("No Fatal occured."), LogLevelFilter.Fatal))
            {
                d.Error("One");
                d.Warn("Warn");
            }
        }